Compare commits

..

5 Commits

4 changed files with 32 additions and 7 deletions

View File

@ -415,7 +415,6 @@ type groupInMemory struct {
sendUpstreamMessage func(*wshandler.UpstreamMessage) sendUpstreamMessage func(*wshandler.UpstreamMessage)
sendEnterRoomMessage func(groupID, accountID) sendEnterRoomMessage func(groupID, accountID)
sendLeaveRoomMessage func(groupID, accountID) sendLeaveRoomMessage func(groupID, accountID)
sendCloseMessage func(accountID, string)
groups groupContainer groups groupContainer
} }
@ -745,7 +744,7 @@ func (gm *groupInMemory) PauseMember(gid primitive.ObjectID, mid primitive.Objec
// 접속은 끊기지만 그룹에서 제거하지는 않는 상태 // 접속은 끊기지만 그룹에서 제거하지는 않는 상태
rconn.unregistOnCloseFunc("member_remove") rconn.unregistOnCloseFunc("member_remove")
rconn.unregistOnCloseFunc("member_remove_invite") rconn.unregistOnCloseFunc("member_remove_invite")
gm.sendCloseMessage(mid, "pause") gm.sendLeaveRoomMessage(gid, mid)
gd := gm.groups.find(gid) gd := gm.groups.find(gid)
if gd == nil { if gd == nil {
@ -971,9 +970,6 @@ func (cfg *groupConfig) prepareInMemory(ctx context.Context, typename string, su
sendLeaveRoomMessage: func(gid groupID, accid accountID) { sendLeaveRoomMessage: func(gid groupID, accid accountID) {
wsh.LeaveRoom(region, gid.Hex(), accid) wsh.LeaveRoom(region, gid.Hex(), accid)
}, },
sendCloseMessage: func(target accountID, text string) {
wsh.SendCloseMessage(region, target.Hex(), text)
},
} }
rpc.RegistReceiver(gm) rpc.RegistReceiver(gm)

View File

@ -2,6 +2,7 @@ package core
import ( import (
"context" "context"
"encoding/json"
"errors" "errors"
"io" "io"
"net" "net"
@ -271,6 +272,28 @@ func (sub *subTavern) clientMessageReceived(sender *wshandler.Sender, messageTyp
sub.cm.add(sender.Accid, sender.Alias) sub.cm.add(sender.Accid, sender.Alias)
} else if messageType == wshandler.Disconnected { } else if messageType == wshandler.Disconnected {
sub.cm.remove(sender.Accid) sub.cm.remove(sender.Accid)
} else if messageType == wshandler.BinaryMessage {
var msg map[string][]any
dec := json.NewDecoder(body)
if err := dec.Decode(&msg); err == nil {
for cmd, args := range msg {
switch cmd {
case "EnterChannel":
sub.wsh.EnterRoom(sub.region, args[0].(string), sender.Accid)
case "LeaveChannel":
sub.wsh.LeaveRoom(sub.region, args[0].(string), sender.Accid)
case "UpdateGroupMemberDocument":
typename := args[0].(string)
gidobj, _ := primitive.ObjectIDFromHex(args[1].(string))
doc := args[2].(map[string]any)
if group := sub.groups[typename]; group != nil {
group.UpdateMemberDocument(gidobj, sender.Accid, doc)
}
}
}
}
} }
} }

4
go.mod
View File

@ -1,11 +1,11 @@
module repositories.action2quare.com/ayo/tavern module repositories.action2quare.com/ayo/tavern
go 1.19 go 1.20
require ( require (
github.com/go-redis/redis/v8 v8.11.5 github.com/go-redis/redis/v8 v8.11.5
go.mongodb.org/mongo-driver v1.11.7 go.mongodb.org/mongo-driver v1.11.7
repositories.action2quare.com/ayo/gocommon v0.0.0-20230711062613-74829b93ac1b repositories.action2quare.com/ayo/gocommon v0.0.0-20230713080645-269fa0f8700e
) )
require ( require (

6
go.sum
View File

@ -116,3 +116,9 @@ repositories.action2quare.com/ayo/gocommon v0.0.0-20230711053010-4acb81a20d9c h1
repositories.action2quare.com/ayo/gocommon v0.0.0-20230711053010-4acb81a20d9c/go.mod h1:ng62uGMGXyQSeuxePG5gJAMtip4Rnspu5Tu7hgvaXns= repositories.action2quare.com/ayo/gocommon v0.0.0-20230711053010-4acb81a20d9c/go.mod h1:ng62uGMGXyQSeuxePG5gJAMtip4Rnspu5Tu7hgvaXns=
repositories.action2quare.com/ayo/gocommon v0.0.0-20230711062613-74829b93ac1b h1:04rlgT+zeKSpekyleb8Mfi8kENIoka5DYJLuk65wqxc= repositories.action2quare.com/ayo/gocommon v0.0.0-20230711062613-74829b93ac1b h1:04rlgT+zeKSpekyleb8Mfi8kENIoka5DYJLuk65wqxc=
repositories.action2quare.com/ayo/gocommon v0.0.0-20230711062613-74829b93ac1b/go.mod h1:ng62uGMGXyQSeuxePG5gJAMtip4Rnspu5Tu7hgvaXns= repositories.action2quare.com/ayo/gocommon v0.0.0-20230711062613-74829b93ac1b/go.mod h1:ng62uGMGXyQSeuxePG5gJAMtip4Rnspu5Tu7hgvaXns=
repositories.action2quare.com/ayo/gocommon v0.0.0-20230711084112-d48d4c0f2189 h1:4ugcv2AlTYjTEtw8ekjCfVzp+xNnNTOHpfWWRbugxvw=
repositories.action2quare.com/ayo/gocommon v0.0.0-20230711084112-d48d4c0f2189/go.mod h1:ng62uGMGXyQSeuxePG5gJAMtip4Rnspu5Tu7hgvaXns=
repositories.action2quare.com/ayo/gocommon v0.0.0-20230713064012-522bd4a597bc h1:ToHccG1AAGFoAVldbJxCv+yBh/GvNyCd74sBp1Hf7YY=
repositories.action2quare.com/ayo/gocommon v0.0.0-20230713064012-522bd4a597bc/go.mod h1:PdpZ16O1czKKxCxn+0AFNaEX/0kssYwC3G8jR0V7ybw=
repositories.action2quare.com/ayo/gocommon v0.0.0-20230713080645-269fa0f8700e h1:94hUQRdZYbsYaTqm/cTI0pEBdp8zdfOSEfkxdO9kS9o=
repositories.action2quare.com/ayo/gocommon v0.0.0-20230713080645-269fa0f8700e/go.mod h1:PdpZ16O1czKKxCxn+0AFNaEX/0kssYwC3G8jR0V7ybw=