本文整理匯總了Golang中github.com/colefan/gsgo/netio/packet.Packet.GetClientFromRawData方法的典型用法代碼示例。如果您正苦於以下問題:Golang Packet.GetClientFromRawData方法的具體用法?Golang Packet.GetClientFromRawData怎麽用?Golang Packet.GetClientFromRawData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/colefan/gsgo/netio/packet.Packet
的用法示例。
在下文中一共展示了Packet.GetClientFromRawData方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: FowardToClient
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)
}
}
示例2: FowardToClient
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())
}
}
示例3: FowardToServer
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())
}
示例4: FowardToServer
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 沒有必要,但留有接口
}