Merge branch 'master' into develop
This commit is contained in:
commit
b796fb4244
@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Room interface {
|
type Room interface {
|
||||||
|
OnPlayerOffline(Player)
|
||||||
}
|
}
|
||||||
|
|
||||||
type RoomMgr interface {
|
type RoomMgr interface {
|
||||||
|
@ -12,8 +12,8 @@ type HandlerMgr struct {
|
|||||||
|
|
||||||
func (this *HandlerMgr) Init() {
|
func (this *HandlerMgr) Init() {
|
||||||
ss.RegHandlerId(int(ss.SSMessageIdE__SS_Ping), constant.WSP_LISTENER_HANDLER_ID)
|
ss.RegHandlerId(int(ss.SSMessageIdE__SS_Ping), constant.WSP_LISTENER_HANDLER_ID)
|
||||||
ss.RegHandlerId(int(ss.SSMessageIdE__SS_WSP_SocketDisconnect), constant.WSP_LISTENER_HANDLER_ID)
|
|
||||||
|
|
||||||
|
ss.RegHandlerId(int(ss.SSMessageIdE__SS_WSP_SocketDisconnect), constant.PLAYER_MGR_HANDLER_ID)
|
||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMPing), constant.PLAYER_MGR_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMPing), constant.PLAYER_MGR_HANDLER_ID)
|
||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMLogin), constant.PLAYER_MGR_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMLogin), constant.PLAYER_MGR_HANDLER_ID)
|
||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMReconnect), constant.PLAYER_MGR_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMReconnect), constant.PLAYER_MGR_HANDLER_ID)
|
||||||
|
@ -27,7 +27,7 @@ func (this *WSPListener) Init() {
|
|||||||
listener, err := net.Listen("tcp", "0.0.0.0:"+
|
listener, err := net.Listen("tcp", "0.0.0.0:"+
|
||||||
q5.ToString(mt.Table.HallCluster.GetListenPort()))
|
q5.ToString(mt.Table.HallCluster.GetListenPort()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
} else {
|
} else {
|
||||||
this.listener = listener
|
this.listener = listener
|
||||||
go this.parseNetPkt()
|
go this.parseNetPkt()
|
||||||
@ -39,9 +39,8 @@ func (this *WSPListener) UnInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *WSPListener) SS_ping(hdr *f5.MsgHdr, msg *ss.SS_Ping) {
|
func (this *WSPListener) SS_ping(hdr *f5.MsgHdr, msg *ss.SS_Ping) {
|
||||||
}
|
rspMsg := ss.SS_Pong{}
|
||||||
|
this.SendProxyMsg(hdr.Conn, 0, &rspMsg)
|
||||||
func (this *WSPListener) SS_WSP_SocketDisconnect(hdr *f5.MsgHdr, msg *ss.SS_WSP_SocketDisconnect) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *WSPListener) accept() {
|
func (this *WSPListener) accept() {
|
||||||
|
@ -13,7 +13,7 @@ type player struct {
|
|||||||
socket f5.WspCliConn
|
socket f5.WspCliConn
|
||||||
accountId string
|
accountId string
|
||||||
sessionId string
|
sessionId string
|
||||||
room *common.Room
|
room common.Room
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *player) GetAccountId() string {
|
func (this *player) GetAccountId() string {
|
||||||
@ -24,17 +24,23 @@ func (this *player) SendMsg(rspMsg proto.Message) {
|
|||||||
GetWspListener().SendProxyMsg(this.socket.Conn, this.socket.SocketHandle, rspMsg)
|
GetWspListener().SendProxyMsg(this.socket.Conn, this.socket.SocketHandle, rspMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *player) GetRoom() *common.Room {
|
func (this *player) GetRoom() common.Room {
|
||||||
return this.room
|
return this.room
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (this *player) init(req *pendingLoginRequest){
|
func (this *player) init(req *pendingLoginRequest){
|
||||||
this.socket = req.hdr.GetSocket()
|
this.socket = req.hdr.GetSocket()
|
||||||
this.accountId = req.msg.GetAccountId()
|
this.accountId = req.msg.GetAccountId()
|
||||||
this.sessionId = req.msg.GetSessionId()
|
this.sessionId = req.msg.GetSessionId()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *player) onOffline(){
|
||||||
|
this.socket.Reset()
|
||||||
|
if this.room != nil {
|
||||||
|
this.room.OnPlayerOffline(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (this *player) CMCreateRoom(hdr *f5.MsgHdr, msg *cs.CMCreateRoom) {
|
func (this *player) CMCreateRoom(hdr *f5.MsgHdr, msg *cs.CMCreateRoom) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package player
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"cs"
|
"cs"
|
||||||
|
"ss"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"f5"
|
"f5"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -178,10 +179,6 @@ func (this *playerMgr) reportServerState(masterIp string, masterPort int32) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *playerMgr) GetPlayers() map[string]*player {
|
|
||||||
return this.accountIdHash
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *playerMgr) getPlayerByAccountId(accountId string) *player {
|
func (this *playerMgr) getPlayerByAccountId(accountId string) *player {
|
||||||
player, ok := this.accountIdHash[accountId]
|
player, ok := this.accountIdHash[accountId]
|
||||||
if ok {
|
if ok {
|
||||||
@ -223,3 +220,12 @@ func (this *playerMgr) genSeqId() *int64 {
|
|||||||
reqId := this.currReqId
|
reqId := this.currReqId
|
||||||
return &reqId
|
return &reqId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *playerMgr) SS_WSP_SocketDisconnect(hdr *f5.MsgHdr, msg *ss.SS_WSP_SocketDisconnect) {
|
||||||
|
hum := this.getPlayerBySocket(hdr.GetSocket())
|
||||||
|
if hum == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
delete(this.socketHash, hdr.GetSocket())
|
||||||
|
hum.onOffline()
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user