Browse Source

修改websock

yjp 5 months ago
parent
commit
5f2907ffd1
1 changed files with 2 additions and 2 deletions
  1. 2 2
      websocket/websocket.go

+ 2 - 2
websocket/websocket.go

@@ -15,7 +15,7 @@ type HandleDisconnectFunc func(groupID string)
 type HandleErrorFunc func(groupID string, err error)
 type HandleCloseFunc func(groupID string, i int, s string) error
 type HandlePongFunc func(groupID string)
-type HandleMessageFunc func(groupID string, message []byte)
+type HandleMessageFunc func(groupID string, message []byte, context any)
 
 var managerInstance *Manager
 
@@ -111,7 +111,7 @@ func (m *Manager) HandleRequest(groupID string, w http.ResponseWriter, r *http.R
 func (m *Manager) HandleMessage(handleMessageFunc HandleMessageFunc) {
 	m.melodyInstance.HandleMessage(func(session *melody.Session, bytes []byte) {
 		if handleMessageFunc != nil {
-			handleMessageFunc(session.Keys[groupIDKey].(string), bytes)
+			handleMessageFunc(session.Keys[groupIDKey].(string), bytes, session.Keys[connectionContextKey])
 		}
 	})
 }