mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
msg server update
This commit is contained in:
parent
3f9c37043c
commit
c12cafae32
@ -73,50 +73,69 @@ func (r *RPCServer) MsgToUser(_ context.Context, in *pbRelay.MsgToUserReq) (*pbR
|
||||
msg["senderPlatformID"] = in.PlatformID
|
||||
mReply["data"] = msg
|
||||
bMsg, _ := json.Marshal(mReply)
|
||||
switch in.GetContentType() {
|
||||
case constant.SyncSenderMsg:
|
||||
log.InfoByKv("come sync", in.OperationID, "args", in.String())
|
||||
RecvID = in.GetSendID()
|
||||
if in.MsgFrom != constant.SysMsgType {
|
||||
for key, conn := range ws.wsUserToConn {
|
||||
UIDAndPID := strings.Split(key, " ")
|
||||
if UIDAndPID[0] == RecvID && utils.PlatformIDToName(in.GetPlatformID()) != UIDAndPID[1] {
|
||||
resultCode := sendMsgToUser(conn, bMsg, in, UIDAndPID[1], UIDAndPID[0])
|
||||
temp := &pbRelay.SingleMsgToUser{
|
||||
ResultCode: resultCode,
|
||||
RecvID: UIDAndPID[0],
|
||||
RecvPlatFormID: utils.PlatformNameToID(UIDAndPID[1]),
|
||||
}
|
||||
resp = append(resp, temp)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
default:
|
||||
log.InfoByKv("not come sync", in.OperationID, "args", in.String())
|
||||
switch in.SessionType {
|
||||
case constant.SingleChatType:
|
||||
log.InfoByKv("come single", in.OperationID, "args", in.String())
|
||||
RecvID = in.GetRecvID()
|
||||
case constant.GroupChatType:
|
||||
RecvID = strings.Split(in.GetRecvID(), " ")[0]
|
||||
default:
|
||||
}
|
||||
log.InfoByKv("come for range", in.OperationID, "args", in.String())
|
||||
|
||||
for key, conn := range ws.wsUserToConn {
|
||||
UIDAndPID := strings.Split(key, " ")
|
||||
if UIDAndPID[0] == RecvID {
|
||||
resultCode := sendMsgToUser(conn, bMsg, in, UIDAndPID[1], UIDAndPID[0])
|
||||
temp := &pbRelay.SingleMsgToUser{
|
||||
ResultCode: resultCode,
|
||||
RecvID: UIDAndPID[0],
|
||||
RecvPlatFormID: utils.PlatformNameToID(UIDAndPID[1]),
|
||||
}
|
||||
resp = append(resp, temp)
|
||||
switch in.GetSessionType() {
|
||||
case constant.SingleChatType:
|
||||
RecvID = in.GetRecvID()
|
||||
case constant.GroupChatType:
|
||||
RecvID = strings.Split(in.GetRecvID(), " ")[0]
|
||||
}
|
||||
log.InfoByKv("test", in.OperationID, "wsUserToConn", ws.wsUserToConn)
|
||||
for key, conn := range ws.wsUserToConn {
|
||||
UIDAndPID := strings.Split(key, " ")
|
||||
if UIDAndPID[0] == RecvID {
|
||||
resultCode := sendMsgToUser(conn, bMsg, in, UIDAndPID[1], UIDAndPID[0])
|
||||
temp := &pbRelay.SingleMsgToUser{
|
||||
ResultCode: resultCode,
|
||||
RecvID: UIDAndPID[0],
|
||||
RecvPlatFormID: utils.PlatformNameToID(UIDAndPID[1]),
|
||||
}
|
||||
resp = append(resp, temp)
|
||||
}
|
||||
}
|
||||
//switch in.GetContentType() {
|
||||
//case constant.SyncSenderMsg:
|
||||
// log.InfoByKv("come sync", in.OperationID, "args", in.String())
|
||||
// RecvID = in.GetSendID()
|
||||
// if in.MsgFrom != constant.SysMsgType {
|
||||
// for key, conn := range ws.wsUserToConn {
|
||||
// UIDAndPID := strings.Split(key, " ")
|
||||
// if UIDAndPID[0] == RecvID && utils.PlatformIDToName(in.GetPlatformID()) != UIDAndPID[1] {
|
||||
// resultCode := sendMsgToUser(conn, bMsg, in, UIDAndPID[1], UIDAndPID[0])
|
||||
// temp := &pbRelay.SingleMsgToUser{
|
||||
// ResultCode: resultCode,
|
||||
// RecvID: UIDAndPID[0],
|
||||
// RecvPlatFormID: utils.PlatformNameToID(UIDAndPID[1]),
|
||||
// }
|
||||
// resp = append(resp, temp)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//default:
|
||||
// log.InfoByKv("not come sync", in.OperationID, "args", in.String())
|
||||
// switch in.SessionType {
|
||||
// case constant.SingleChatType:
|
||||
// log.InfoByKv("come single", in.OperationID, "args", in.String())
|
||||
// RecvID = in.GetRecvID()
|
||||
// case constant.GroupChatType:
|
||||
// RecvID = strings.Split(in.GetRecvID(), " ")[0]
|
||||
// default:
|
||||
// }
|
||||
// log.InfoByKv("come for range", in.OperationID, "args", in.String())
|
||||
//
|
||||
// for key, conn := range ws.wsUserToConn {
|
||||
// UIDAndPID := strings.Split(key, " ")
|
||||
// if UIDAndPID[0] == RecvID {
|
||||
// resultCode := sendMsgToUser(conn, bMsg, in, UIDAndPID[1], UIDAndPID[0])
|
||||
// temp := &pbRelay.SingleMsgToUser{
|
||||
// ResultCode: resultCode,
|
||||
// RecvID: UIDAndPID[0],
|
||||
// RecvPlatFormID: utils.PlatformNameToID(UIDAndPID[1]),
|
||||
// }
|
||||
// resp = append(resp, temp)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
return &pbRelay.MsgToUserResp{
|
||||
Resp: resp,
|
||||
}, nil
|
||||
|
@ -57,11 +57,13 @@ func (ws *WServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func (ws *WServer) readMsg(conn *websocket.Conn) {
|
||||
for {
|
||||
_, msg, err := conn.ReadMessage()
|
||||
msgType, msg, err := conn.ReadMessage()
|
||||
if err != nil {
|
||||
log.ErrorByKv("WS ReadMsg error", "", "userIP", conn.RemoteAddr().String(), "userUid", ws.getUserUid(conn), "error", err)
|
||||
ws.delUserConn(conn)
|
||||
return
|
||||
} else {
|
||||
log.ErrorByKv("test", "", "msgType", msgType, "userIP", conn.RemoteAddr().String(), "userUid", ws.getUserUid(conn))
|
||||
}
|
||||
ws.msgParse(conn, msg)
|
||||
//ws.writeMsg(conn, 1, chat)
|
||||
|
Loading…
x
Reference in New Issue
Block a user