reconnection
This commit is contained in:
parent
68430a966b
commit
095deb582b
@ -89,6 +89,10 @@ const (
|
||||
// Err code
|
||||
ERR_CODE_OK = 0
|
||||
|
||||
// Login and Reconnect
|
||||
ERR_CODE_RECONNECT_PLAYER_NO_EXISTS = 10001
|
||||
ERR_CODE_RECONNECT_PLAYER_SESSION_ID_NO_VALID = 10002
|
||||
|
||||
// Friemds
|
||||
ERR_CODE_USERS_NO_EXISTS = 11001
|
||||
ERR_CODE_FRIENDSHIP_IS_FULL = 11002
|
||||
|
@ -14,6 +14,7 @@ func (this *HandlerMgr) init() {
|
||||
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMPing), PLAYER_MGR_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMLogin), PLAYER_MGR_HANDLER_ID)
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMReconnect), PLAYER_MGR_HANDLER_ID)
|
||||
|
||||
// 好友
|
||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSearchUser), PLAYER_HANDLER_ID)
|
||||
|
@ -27,6 +27,18 @@ func (p *Player) GetSessionId() string {
|
||||
return p.sessionId
|
||||
}
|
||||
|
||||
func (p *Player) SendMsg(rspMsg proto.Message) {
|
||||
wspListener.sendProxyMsg(p.socket.Conn, p.socket.SocketHandle, rspMsg)
|
||||
}
|
||||
|
||||
func (p *Player) ReBind(socket f5.WspCliConn) {
|
||||
if p.socket.IsValid() {
|
||||
delete(playerMgr.socketHash, p.socket)
|
||||
}
|
||||
p.socket = socket
|
||||
playerMgr.socketHash[p.socket] = p
|
||||
}
|
||||
|
||||
// CMSearchUser 搜索用户
|
||||
func (p *Player) CMSearchUser(hdr *f5.MsgHdr, msg *cs.CMSearchUser) {
|
||||
sinceId := msg.GetSinceId()
|
||||
@ -279,10 +291,6 @@ func (p *Player) MarkNewMsg() {
|
||||
p.SendMsg(rspMsg)
|
||||
}
|
||||
|
||||
func (p *Player) SendMsg(rspMsg proto.Message) {
|
||||
wspListener.sendProxyMsg(p.socket.Conn, p.socket.SocketHandle, rspMsg)
|
||||
}
|
||||
|
||||
func IsValidChatChannel(chatChannel int32) bool {
|
||||
return chatChannel > kCCBegin && chatChannel < kCCEnd
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"f5"
|
||||
"fmt"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"mt"
|
||||
"q5"
|
||||
)
|
||||
@ -198,3 +199,22 @@ func (this *PlayerMgr) GetOnlineStatus(accountId string) int32 {
|
||||
}
|
||||
return OnlineStatusOff
|
||||
}
|
||||
|
||||
func (this *PlayerMgr) CMReconnect(hdr *f5.MsgHdr, msg *cs.CMReconnect) {
|
||||
hum := this.GetPlayerByAccountId(msg.GetAccountId())
|
||||
rspMsg := &cs.SMReconnect{}
|
||||
if hum == nil {
|
||||
rspMsg.Errcode = proto.Int32(ERR_CODE_RECONNECT_PLAYER_NO_EXISTS)
|
||||
rspMsg.Errmsg = proto.String("player no exists")
|
||||
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||
return
|
||||
}
|
||||
if hum.GetSessionId() != msg.GetSessionId() {
|
||||
rspMsg.Errcode = proto.Int32(ERR_CODE_RECONNECT_PLAYER_SESSION_ID_NO_VALID)
|
||||
rspMsg.Errmsg = proto.String("session id no valid")
|
||||
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||
return
|
||||
}
|
||||
hum.ReBind(hdr.GetSocket())
|
||||
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user