Exemplo n.º 1
0
func init() {
	handle := dispatch.NewHandleConditions()
	//系统消息
	handle.Add(dispatch.HandleCondition{
		Condition: systemProto.IsValidID,
		H: dispatch.Handle{
			systemProto.ID_System_ConnectDBServerS2C: connectDBServerCallBack,
		},
	})
	//DB消息
	handle.Add(dispatch.HandleFuncCondition{
		Condition: dbProto.IsValidID,
		H: func(session *link.Session, msg []byte) {
			identification := binary.GetUint64LE(msg[2:10])
			var userSession *link.Session = global.GetSession(identification)
			if userSession == nil {
				return
			}
			dbMsgChan := userSession.State.(chan []byte)
			dbMsgChan <- msg
		},
	})

	//创建消息分派
	clientMsgDispatch = dispatch.NewDispatch(handle)
}
Exemplo n.º 2
0
func init() {
	handle := dispatch.NewHandleConditions()
	//系统消息处理
	handle.Add(dispatch.HandleCondition{
		Condition: systemProto.IsValidID,
		H: dispatch.Handle{
			systemProto.ID_System_ConnectWorldServerS2C: connectWorldServerCallBack,
		},
	})
	//游戏消息处理
	handle.Add(dispatch.HandleFuncCondition{
		Condition: gameProto.IsValidID,
		H: func(session *link.Session, msg []byte) {
			//发送到用户客户端
			msgIdentification := binary.GetUint64LE(msg[2:10])
			userSession := global.GetSession(msgIdentification)
			if userSession == nil {
				return
			}
			protos.Send(userSession, msg)
		},
	})

	//创建消息分派
	clientMsgDispatch = dispatch.NewDispatch(handle)
}
func init() {
	handle := dispatch.NewHandleConditions()
	//系统消息处理
	handle.Add(dispatch.HandleCondition{
		Condition: systemProto.IsValidID,
		H: dispatch.Handle{
			systemProto.ID_System_ConnectTransferServerC2S: connectTransferServer,
			systemProto.ID_System_ClientLoginSuccessC2S:    clientLoginSuccess,
		},
	})
	//游戏消息处理
	handle.Add(dispatch.HandleFuncCondition{
		Condition: gameProto.IsValidID,
		H: func(session *link.Session, msg []byte) {
			sendToGateServer(msg)
		},
	})

	//创建消息分派
	serverMsgDispatch = dispatch.NewDispatch(handle)
}
Exemplo n.º 4
0
func init() {
	handle := dispatch.NewHandleConditions()
	//系统消息处理
	handle.Add(dispatch.HandleCondition{
		Condition: systemProto.IsValidID,
		H: dispatch.Handle{
			systemProto.ID_System_ConnectWorldServerC2S:   connectWorldServer,
			systemProto.ID_System_ClientSessionOfflineC2S: setSessionOffline,
			systemProto.ID_System_ClientLoginSuccessC2S:   setClientLoginSuccess,
		},
	})
	//游戏消息处理
	handle.Add(dispatch.HandleFuncCondition{
		Condition: gameProto.IsValidID,
		H: func(session *link.Session, msg []byte) {
			dealGameMsg(msg)
		},
	})

	//创建消息分派
	serverMsgDispatch = dispatch.NewDispatch(handle)
}
func init() {
	handle := dispatch.NewHandleConditions()
	//系统消息处理
	handle.Add(dispatch.HandleCondition{
		Condition: systemProto.IsValidID,
		H: dispatch.Handle{
			systemProto.ID_System_ConnectTransferServerS2C: connectTransferServerCallBack,
			systemProto.ID_System_ClientSessionOnlineC2S:   setSessionOnline,
			systemProto.ID_System_ClientSessionOfflineC2S:  setSessionOffline,
			systemProto.ID_System_ClientLoginSuccessC2S:    setClientLoginSuccess,
		},
	})
	//LoginServer消息
	handle.Add(dispatch.HandleFuncCondition{
		Condition: gameProto.IsValidLoginID,
		H: func(session *link.Session, msg []byte) {
			dealGameMsg(msg)
		},
	})
	//GameServer消息
	handle.Add(dispatch.HandleFuncCondition{
		Condition: gameProto.IsValidGameID,
		H: func(session *link.Session, msg []byte) {
			dealGameMsg(msg)
		},
	})
	//WorldServer消息
	handle.Add(dispatch.HandleFuncCondition{
		Condition: gameProto.IsValidWorldID,
		H: func(session *link.Session, msg []byte) {
			worldProxy.SendGameMsgToServer(msg)
		},
	})

	//创建消息分派
	clientMsgDispatch = dispatch.NewDispatch(handle)
}