This commit is contained in:
aozhiwei 2023-09-12 13:48:17 +08:00
parent d2607bec10
commit a6413c9ab2
6 changed files with 34 additions and 3 deletions

View File

@ -22,6 +22,7 @@ type Player interface {
GetRoom() Room
SetRoom(Room)
GetAccountId() string
GetSessionId() string
GetName() string
GetAvatarUrl() string
GetHeroId() int32

View File

@ -74,3 +74,7 @@ func (this *player) GetZoneId() int32 {
func (this *player) GetNodeId() int32 {
return 0
}
func (this *player) GetSessionId() string {
return this.sessionId
}

View File

@ -238,3 +238,25 @@ func (this *playerMgr) SS_WSP_SocketDisconnect(hdr *f5.MsgHdr, msg *ss.SS_WSP_So
delete(this.socketHash, hdr.GetSocket())
hum.onOffline()
}
func (this *playerMgr) CMReconnect(hdr *f5.MsgHdr, msg *cs.CMReconnect) {
hum := this.internalGetPlayerByAccountId(msg.GetAccountId())
rspMsg := &cs.SMReconnect{}
if hum == nil {
rspMsg.Errcode = proto.Int32(1)
rspMsg.Errmsg = proto.String("")
GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
return
}
if hum.GetSessionId() != msg.GetSessionId() {
rspMsg.Errcode = proto.Int32(1)
rspMsg.Errmsg = proto.String("")
GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
return
}
if hum.socket.IsValid() {
delete(this.socketHash, hum.socket)
}
this.socketHash[hdr.GetSocket()] = hum
GetWspListener().SendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
}

View File

@ -181,7 +181,8 @@ message SMReconnect
//
message CMCreateRoom
{
optional string passwd = 1; //
optional int32 map_id = 1; //id
optional string passwd = 2; //
}
message SMCreateRoom

View File

@ -29,10 +29,13 @@ type room struct {
startTimer *f5.TimerWp
}
func (this *room) init(roomId string, roomIdx int64, owner common.Player, passwd string) {
func (this *room) init(roomId string, roomIdx int64, mapId int32, owner common.Player, passwd string) {
this.roomId = roomId
this.roomIdx = roomIdx
this.entry.Init(this)
this.config.mapId = mapId
this.config.zoneId = owner.GetZoneId()
this.config.nodeId = owner.GetNodeId()
this.config.passwd = passwd
this.owner = newMember(owner)
this.members = map[string]*member{

View File

@ -62,7 +62,7 @@ func (this *roomMgr) CMCreateRoom(hdr *f5.MsgHdr, msg *cs.CMCreateRoom) {
return
}
m := new(room)
m.init(q5.ToString(this.genRoomId()), this.genRoomIdx(), hum, msg.GetPasswd())
m.init(q5.ToString(this.genRoomId()), this.genRoomIdx(), msg.GetMapId(), hum, msg.GetPasswd())
this.idHash[m.roomId] = m
hum.SendMsg(rspMsg)