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