tt
This commit is contained in:
@@ -17,16 +17,16 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *userManager) Add(cid int32, client *Client) {
|
||||
func (m *userManager) Add(uid int32, client *Client) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
m.userMap[cid] = client
|
||||
m.userMap[uid] = client
|
||||
}
|
||||
|
||||
func (m *userManager) Delete(cid int32) {
|
||||
func (m *userManager) Delete(uid int32) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
delete(m.userMap, cid)
|
||||
delete(m.userMap, uid)
|
||||
}
|
||||
|
||||
func (m *userManager) GetAll() map[int32]*Client {
|
||||
|
||||
@@ -26,8 +26,8 @@ type ISocketServer interface {
|
||||
|
||||
// ISocketConn 由网络层实现
|
||||
type ISocketConn interface {
|
||||
GetParam(key string) interface{}
|
||||
SetParam(key string, values interface{})
|
||||
GetParam(key string) string
|
||||
SetParam(key string, values string)
|
||||
Write(data []byte) error
|
||||
Close() error
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func (s *WSServer) OnOpen(c gnet.Conn) ([]byte, gnet.Action) {
|
||||
curHeader: nil,
|
||||
cachedBuf: bytes.Buffer{},
|
||||
},
|
||||
param: make(map[string]interface{}),
|
||||
param: make(map[string]string),
|
||||
}
|
||||
c.SetContext(ws)
|
||||
s.unUpgradeConn.Store(c.RemoteAddr().String(), ws)
|
||||
|
||||
@@ -19,7 +19,7 @@ type WSConn struct {
|
||||
logger logging.Logger
|
||||
isUpgrade bool
|
||||
isClose bool
|
||||
param map[string]interface{}
|
||||
param map[string]string
|
||||
openTime int64
|
||||
wsMessageBuf
|
||||
}
|
||||
@@ -163,15 +163,17 @@ func (w *WSConn) OnRequest(u []byte) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
w.SetParam("query", parsedURL.Query())
|
||||
for key, value := range parsedURL.Query() {
|
||||
w.SetParam(key, value[0])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *WSConn) GetParam(key string) interface{} {
|
||||
func (w *WSConn) GetParam(key string) string {
|
||||
return w.param[key]
|
||||
}
|
||||
|
||||
func (w *WSConn) SetParam(key string, values interface{}) {
|
||||
func (w *WSConn) SetParam(key string, values string) {
|
||||
w.param[key] = values
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user