sneakpeek 함수 추가
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"repositories.action2quare.com/ayo/gocommon"
|
||||
"repositories.action2quare.com/ayo/gocommon/wshandler"
|
||||
)
|
||||
|
||||
@ -18,6 +19,7 @@ type connWithFriends struct {
|
||||
type connections struct {
|
||||
connLock sync.Mutex
|
||||
conns map[primitive.ObjectID]*connWithFriends
|
||||
redison *gocommon.RedisonHandler
|
||||
}
|
||||
|
||||
func (cs *connections) new(accid primitive.ObjectID, conn *websocket.Conn) {
|
||||
@ -93,14 +95,17 @@ func (cs *connections) writeMessage(acc primitive.ObjectID, src any) {
|
||||
|
||||
func (cs *connections) ClientConnected(conn *websocket.Conn, callby *wshandler.Sender) {
|
||||
cs.new(callby.Accid, conn)
|
||||
cs.redison.JSONSet(callby.Accid.Hex(), "$", map[string]any{}, gocommon.RedisonSetOptionNX)
|
||||
}
|
||||
|
||||
func (cs *connections) ClientDisconnected(msg string, callby *wshandler.Sender) {
|
||||
cs.redison.JSONDel(callby.Accid.Hex(), "$")
|
||||
cs.delete(callby.Accid)
|
||||
}
|
||||
|
||||
func makeConnections() *connections {
|
||||
func makeConnections(redison *gocommon.RedisonHandler) *connections {
|
||||
return &connections{
|
||||
conns: make(map[primitive.ObjectID]*connWithFriends),
|
||||
conns: make(map[primitive.ObjectID]*connWithFriends),
|
||||
redison: redison,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user