Example #1
0
func (this *WorldServer) HandleClient(session *libnet.Session) {
	defer waitgroup.Done()
	defer session.Close()
	for {
		msg := new(msgcmd.Cmd)
		err := session.Receive(msg)
		if err != nil {
			println("World Server Error: 接收数据 失败. ", err.Error())
			logFile.Printf("World Server Error: 接收数据 失败. ", err.Error())
			break
		}
		if msg == nil {
			continue
		}
		switch msg.Mid {
		case msgcmd.MCMD_M2W_REGISTER:
			this.DoRegister(msg, session)
		case msgcmd.MCMD_M2W_LOGIN:
			this.DoLogin(msg, session)
		case msgcmd.MCMD_M2W_USEROFFLINE:
			this.DoUserOffline(msg, session)
		case msgcmd.MCMD_M2W_HEARTBEAT:
			this.DoHeartBeat(session)
		case msgcmd.MCMD_M2W_REQUEST_ONLINEUSERS:
			this.DoRequestOnlineUsers(msg, session)
		}
	}
}
Example #2
0
func (this *MsgServer) HandleKeyClient(session *libnet.Session) {
	defer waitgroup.Done()
	defer session.Close()
	//Client 连接 Msg Key Server 后, 发送 RC4 秘钥给 Client
	cmd := msgcmd.NewCmd(msgcmd.MCMD_RESPONSERC4KEY)
	cmd.AddArg(this.customCodec.GetKey())
	if err := session.Send(cmd); err != nil {
		println("Msg Key Server Error: 发送 RC4 Key 失败. ", err.Error())
		logFile.Printf("Msg Key Server Error: 发送 RC4 Key 失败. ", err.Error())
		return
	}
}
Example #3
0
func (this *WorldServer) HandleKeyClient(session *libnet.Session) {
	defer waitgroup.Done()
	defer session.Close()
	//Msg Server 连接 WS 的 Key Server 后,WS 发送 RC4 秘钥给 Msg Server
	cmd := msgcmd.NewCmd(msgcmd.MCMD_RESPONSERC4KEY)
	cmd.AddArg(this.cfg.Rc4Key)
	if err := session.Send(cmd); err != nil {
		println("World Server Error: 发送 RC4 Key 失败. ", err.Error())
		logFile.Printf("World Server Error: 发送 RC4 Key 失败. ", err.Error())
		return
	}
}
Example #4
0
func (this *Gateway) HandleClient(session *libnet.Session, index uint) {
	defer waitgroup.Done()
	defer session.Close()

	var serverAddr string = this.cfg.MsgServerList[index]
	var keyAddr string = getKeyServerAddr(serverAddr)

	//主动应答 MS Server Addr 和 Key Server Addr 给 Client
	cmd := msgcmd.NewCmd(msgcmd.MCMD_G2C_RESPONSEMSADDR)
	cmd.AddArg(serverAddr)
	cmd.AddArg(keyAddr)
	if err := session.Send(cmd); err != nil {
		println("GateWay Error: 发送Msg Server 地址信息失败. ", err.Error())
		logFile.Printf("GateWay Error: 发送Msg Server 地址信息失败. %s", err.Error())
		return
	}
}