Esempio n. 1
0
func (this *LoginHandler) loginReq(pack *packet.Packet, conn netio.ConnInf) {
	//TODO
	if conn.GetBindObj() != nil {
		//登录后在发登录请求,这是不对的。应该剔除
		Log.Error("第一次消息请求时,应该没有已经绑定的对象,说明用户已经有绑定的对象了,是个错误的请求")
		return
	}
	if pack.DecodePacket() == false {

	}

	var loginReq p_login.PlayerLoginReq
	loginReq.Packet = pack
	if false == loginReq.DecodePacket() {
		Log.Error("解析包错误,应该断开连接")
		conn.Close()
		return
	}

	var uid uint64
	var account string
	var superpwd string
	uid = loginReq.UserID
	account = loginReq.UserName
	superpwd = loginReq.UserPwd

	if config.GetServerConfig().GetXmlConf().Server.AccessPtMode == 1 {
		//平台接入模式,要查看平台登录信息
	} else {
		//非平台接入模式,只要查看自己的登录信息即可
	}

}
Esempio n. 2
0
func (rule *GsForwardRule) FowardToClient(cmdId uint16, pack *packet.Packet, conn netio.ConnInf) {
	clientID := pack.ID
	client := ClientManagerInst.FindClientByUserID(clientID)
	if client != nil {
		if cmdId == protocol_proxy.CMD_C_P_USER_OFFLINE_REQ {
			client.GetPhysicalLink().Close()
		} else {
			client.GetPhysicalLink().Write(pack.GetClientFromRawData())
		}
	} else {
		ProxyLog.Error("GS msg can't find physical net conn ,user_id = ", clientID)
	}

}
Esempio n. 3
0
func (rule *LsForwardRule) FowardToClient(cmdID uint16, pack *packet.Packet, conn netio.ConnInf) {
	clientID := pack.ID
	var client *ProxyClient
	if cmdID <= protocol_login.CMD_C_LOGIN_VALID_RESP {
		client = ClientManagerInst.FindClientByConnID(clientID)
	} else {
		client = ClientManagerInst.FindClientByUserID(clientID)
	}

	if client == nil {
		ProxyLog.Error("LS msg can't find physical conn,conn_id = ", clientID, " cmd_id = ", cmdID)
		return
	}

	switch cmdID {
	case protocol_proxy.CMD_C_P_USER_OFFLINE_REQ:
		client.GetPhysicalLink().Close()
	case protocol_login.CMD_C_LOGIN_VALID_RESP:
		if pack.ErrCode == 0 {
			loginValid := &protocol_login.LoginValidResp{}
			loginValid.Packet = pack
			if loginValid.DecodePacket() {
				client.GetPhysicalLink().SetBsStatus(BS_STATUS_AUTHED)
				client.GetPhysicalLink().SetUID(loginValid.UserId)
				oldClient := ClientManagerInst.ChangeClientFromConnIDtoUserID(client)
				if oldClient != nil && oldClient.GetPhysicalLink() != nil {
					oldClient.GetPhysicalLink().Close()
				}

			} else {
				loginValid.Packet = packet.NewEmptyPacket()
				loginValid.ErrCode = PROXY_FORWARD_DECODE_ERR
				loginValid.CmdID = protocol_login.CMD_C_LOGIN_VALID_RESP
				buf := loginValid.EncodePacket(128)
				client.GetPhysicalLink().Write(buf.GetData())
			}

		} else {
			client.GetPhysicalLink().Write(pack.GetClientFromRawData())
		}

	default:
		client.GetPhysicalLink().Write(pack.GetClientFromRawData())
	}

}
Esempio n. 4
0
func (rule *GsForwardRule) FowardToServer(client *ProxyClient, cmdId uint16, pack *packet.Packet, conn netio.ConnInf) {
	server := client.GetGsRoute()
	if server == nil {
		errorResponse(cmdId, EC_GSROUTE_IS_NIL, pack.ID, conn)
		return
	}
	serverLink := client.GetPhysicalLink()
	if serverLink == nil {
		errorResponse(cmdId, EC_GSROUTE_IS_NIL, pack.ID, conn)
		return
	}
	if serverLink.GetBsStatus() != BS_STATUS_AUTHED {
		errorResponse(cmdId, EC_GSROUTE_IS_UNAUTHED, pack.ID, conn)
		return
	}
	serverLink.Write(pack.GetClientFromRawData())
}
Esempio n. 5
0
func (rule *LsForwardRule) FowardToServer(client *ProxyClient, cmdID uint16, pack *packet.Packet, conn netio.ConnInf) {
	if code := rule.preRule(pack); code != 0 {
		errorResponse(cmdID, uint16(code), pack.ID, conn)
		return
	}
	server := client.GetLsRoute()
	if server == nil {
		errorResponse(cmdID, EC_LSROUTE_IS_NIL, pack.ID, conn)
		return
	}
	serverLink := server.GetPhysicalLink()
	if serverLink == nil {
		errorResponse(cmdID, EC_LSROUTE_IS_NIL, pack.ID, conn)
		return
	}

	if serverLink.GetBsStatus() != BS_STATUS_AUTHED {
		errorResponse(cmdID, EC_LSROUTE_IS_UNAUTHED, pack.ID, conn)
		return
	}
	serverLink.Write(pack.GetClientFromRawData())
	//rule.postRule(pack)//TODO 没有必要,但留有接口

}