Exemple #1
0
func IsMsgGate(vTMsgType bsn_common.TMsgType) bool {
	if vTMsgType < bsn_common.TMsgType(bsn_msg_gate_server.ECmdGate2Server_CmdGate2Server_Min) {
		return false
	}
	if vTMsgType > bsn_common.TMsgType(bsn_msg_gate_server.ECmdGate2Server_CmdGate2Server_Max) {
		return false
	}
	return true
}
Exemple #2
0
func IsMsgEchoServer(vTMsgType bsn_common.TMsgType) bool {
	if vTMsgType < bsn_common.TMsgType(bsn_msg_client_echo_server.ECmdEchoServe2Client_CmdEchoServer2Client_Min) {
		return false
	}
	if vTMsgType > bsn_common.TMsgType(bsn_msg_client_echo_server.ECmdEchoServe2Client_CmdEchoServer2Client_Max) {
		return false
	}
	return true
}
Exemple #3
0
func IsMsgSys(vTMsgType bsn_common.TMsgType) bool {
	if vTMsgType < bsn_common.TMsgType(bsn_define.ECmd_Cmd_Min) {
		return false
	}
	if vTMsgType > bsn_common.TMsgType(bsn_define.ECmd_Cmd_Max) {
		return false
	}
	return true
}
Exemple #4
0
func IsMsgGate(vTMsgType bsn_common.TMsgType) bool {
	if vTMsgType < bsn_common.TMsgType(bsn_msg_gate_gateconfig.ECmdGate2GateConfig_CmdGate2GateConfig_Min) {
		return false
	}
	if vTMsgType > bsn_common.TMsgType(bsn_msg_gate_gateconfig.ECmdGate2GateConfig_CmdGate2GateConfig_Max) {
		return false
	}
	return true
}
Exemple #5
0
func IsMsgClient(vTMsgType bsn_common.TMsgType) bool {
	if vTMsgType < bsn_common.TMsgType(bsn_msg_client_gate.ECmdClient2Gate_CmdClient2Gate_Min) {
		return false
	}
	if vTMsgType > bsn_common.TMsgType(bsn_msg_client_gate.ECmdClient2Gate_CmdClient2Gate_Max) {
		return false
	}
	return true
}
Exemple #6
0
func (this *SServerUser) ProcMsg_CmdServer2Gate_GetClientMsgRangeRes() (err error) {
	GSLog.Debugln("ProcMsg_CmdServer2Gate_GetClientMsgRangeRes")

	recvMsg := new(bsn_msg_gate_server.SGetClientMsgRangeRes)
	if err = proto.Unmarshal(this.M_by2MsgBody, recvMsg); err != nil {
		return
	}
	GSLog.Debugln(recvMsg.GetVu32MsgTypeMin(), recvMsg.GetVu32MsgTypeMax())

	this.M_MsgTypeMin = bsn_common.TMsgType(recvMsg.GetVu32MsgTypeMin())
	this.M_MsgTypeMax = bsn_common.TMsgType(recvMsg.GetVu32MsgTypeMax())

	return
}
Exemple #7
0
func (this *SClientUser) send_CmdServer2Gate_LoginRes(vResult bsn_msg_gate_server.SLoginRes_EResult) error {
	sendMsg := &bsn_msg_gate_server.SLoginRes{
		Result:     vResult.Enum(),
		ServerType: bsn_define.EServerType_ServerType_Echo.Enum(),
	}
	return this.SendPbMsgWithSMsgHeader(bsn_common.TMsgType(bsn_msg_gate_server.ECmdServe2Gate_CmdServer2Gate_LoginRes), sendMsg)
}
Exemple #8
0
func (this *SClientUser) send_CmdServer2Gate_GetClientMsgRangeRes() error {
	sendMsg := &bsn_msg_gate_server.SGetClientMsgRangeRes{
		Vu32MsgTypeMin: proto.Uint32(uint32(bsn_msg_client_echo_server.ECmdClient2EchoServer_CmdClient2EchoServer_Min)),
		Vu32MsgTypeMax: proto.Uint32(uint32(bsn_msg_client_echo_server.ECmdClient2EchoServer_CmdClient2EchoServer_Max)),
	}
	return this.SendPbMsgWithSMsgHeader(bsn_common.TMsgType(bsn_msg_gate_server.ECmdServe2Gate_CmdServer2Gate_GetClientMsgRangeRes), sendMsg)
}
Exemple #9
0
func (this *SServerUser) send_CmdGate2Server_ClientMsg(vSClientUser *SClientUser) bool {
	vSMsg_Gate2Server_ClientMsg := new(bsn_msg.SMsg_Gate2Server_ClientMsg)
	vSMsg_Gate2Server_ClientMsg.Fill(uint16(vSClientUser.Id()), vSClientUser.M_SMsgHeader, vSClientUser.M_by2MsgBody)
	this.SendMsgWithSMsgHeader(bsn_common.TMsgType(bsn_msg_gate_server.ECmdGate2Server_CmdGate2Server_ClientMsg), vSMsg_Gate2Server_ClientMsg.Serialize())

	return true
}
Exemple #10
0
func (this *SClientUser) SendPb2Client(vTClientId TClientId, msgType bsn_msg_client_echo_server.ECmdEchoServe2Client, iMessage proto.Message) error {
	byMsg, err := proto.Marshal(iMessage)
	if err != nil {
		GSLog.Errorln(err)
		return err
	}

	byData := bsn_msg.NewMsgWithMsgHeader(bsn_common.TMsgType(msgType), byMsg)
	return this.Send2Client(vTClientId, byData)
}
Exemple #11
0
func (this *SServerUser) send_CmdGate2Server_LoginReq(vEServerType bsn_define.EServerType) (err error) {
	vSApp := this.UserMgr().UserMgr().App()

	sendMsg := &bsn_msg_gate_server.SLoginReq{
		Id:         proto.Uint32(vSApp.Id()),
		ServerType: vEServerType.Enum(),
	}

	return this.SendPbMsgWithSMsgHeader(bsn_common.TMsgType(bsn_msg_gate_server.ECmdGate2Server_CmdGate2Server_LoginReq), sendMsg)
}
Exemple #12
0
func (this *SMsgHeader) DeSerialize(byDatas []byte) bsn_common.TMsgLen {
	var vTMsgLen bsn_common.TMsgLen = 0

	this.M_TMsgType = bsn_common.TMsgType(binary.LittleEndian.Uint16(byDatas[vTMsgLen:]))
	vTMsgLen += 2
	this.M_TMsgLen = bsn_common.TMsgLen(binary.LittleEndian.Uint16(byDatas[vTMsgLen:]))
	vTMsgLen += 2

	return vTMsgLen
}
Exemple #13
0
func NewClient2GateMsg(vu8ServerType, vu8ServerId uint8, u16Type uint16, byMsg []byte) []byte {
	vTMsgLen := bsn_common.TMsgLen(len(byMsg))
	vSMsgHeader := NewMsgHeader(bsn_common.TMsgType(u16Type), vTMsgLen)
	vSMsgHeaderGateClient := NewMsgHeaderGateClient(vu8ServerType, vu8ServerId, vTMsgLen+bsn_common.TMsgLen(unsafe.Sizeof(*vSMsgHeader)))

	byData := make([]byte, vSMsgHeaderGateClient.Len()+bsn_common.TMsgLen(unsafe.Sizeof(*vSMsgHeaderGateClient)))
	copy(byData, vSMsgHeaderGateClient.Serialize())
	copy(byData[int(unsafe.Sizeof(*vSMsgHeaderGateClient)):], vSMsgHeader.Serialize())
	copy(byData[int(unsafe.Sizeof(*vSMsgHeaderGateClient))+int(unsafe.Sizeof(*vSMsgHeader)):], byMsg)
	GSLog.Debugln("byData= ", byData)
	return byData
}
func (this *SServerUserGate) ProcMsg_CmdGate2Client_TestReq() (err error) {
	GSLog.Debugln("ProcMsg_CmdGate2Client_TestReq")

	recvMsg := new(bsn_msg_client_gate.STestReq)
	if err = proto.Unmarshal(this.M_by2MsgBody, recvMsg); err != nil {
		return
	}
	GSLog.Debugln(*recvMsg.VstrInfo)

	sendMsg := &bsn_msg_client_gate.STestRes{
		VstrInfo: proto.String("client test res"),
	}
	this.SendPbMsgWithSMsgHeader(bsn_common.TMsgType(bsn_msg_client_gate.ECmdClient2Gate_CmdClient2Gate_TestRes), sendMsg)

	return
}
Exemple #15
0
func (this *SClientUser) ProcMsg_CmdGate2GateConfig_GetServerConfigReq() (err error) {
	GSLog.Debugln("ProcMsg_CmdGate2GateConfig_GetServerConfigReq")

	recvMsg := new(bsn_msg_gate_gateconfig.SGate2GateConfig_GetServerConfigReq)
	if err = proto.Unmarshal(this.M_by2MsgBody, recvMsg); err != nil {
		return
	}

	sendMsg := &bsn_msg_gate_gateconfig.SGateConfig2Gate_GetServerConfigRes{
		VSServerConfigs: []*bsn_msg_gate_gateconfig.SServerConfig{
			&bsn_msg_gate_gateconfig.SServerConfig{
				Vcommon_EServerType: bsn_define.EServerType_ServerType_Echo.Enum(),
				VstrAddr:            proto.String("localhost:" + strconv.Itoa(int(bsn_common.ServerPort(uint32(bsn_define.EServerType_ServerType_Echo), this.UserMgr().UserMgr().App().Id())))),
			},
		},
	}
	return this.SendPbMsgWithSMsgHeader(bsn_common.TMsgType(bsn_msg_gate_gateconfig.ECmdGateConfig2Gate_CmdGateConfig2Gate_GetServerConfigRes), sendMsg)
}
Exemple #16
0
func WriteMsgWithMsgHeader(conn net.Conn, u16Type uint16, byData []byte) (err error) {
	vTMsgLen := bsn_common.TMsgLen(len(byData))
	vSMsgHeader := NewMsgHeader(bsn_common.TMsgType(u16Type), vTMsgLen)

	_, err = conn.Write(vSMsgHeader.Serialize())
	if err != nil {
		return
	}

	if vTMsgLen > 0 {
		_, err = conn.Write(byData)
		if err != nil {
			return
		}
	}

	return
}
Exemple #17
0
func (this *SSession) Pong(byMsg []byte) error {
	return this.SendMsgWithSMsgHeader(bsn_common.TMsgType(bsn_define.ECmd_Cmd_Pong), byMsg)
}
Exemple #18
0
func (this *SServerUserGate) TestReq2EchoServer() {
	sendMsg := &bsn_msg_client_echo_server.STestReq{
		VstrInfo: proto.String("client test req"),
	}
	this.SendPbMsgWithSMsgHeader(bsn_common.TMsgType(bsn_msg_client_echo_server.ECmdClient2EchoServer_CmdClient2EchoServer_TestReq), sendMsg)
}
Exemple #19
0
func NewMsgHeaderGateServer(vTGateServerMsgType bsn_common.TGateServerMsgType, vTGroupId bsn_common.TGateGroupId, vTGateUserId bsn_common.TGateUserId, vTMsgLen bsn_common.TMsgLen) *SMsgHeaderGateServer {
	this := &SMsgHeaderGateServer{}
	this.Fill(vTGroupId, vTGateUserId)
	this.SMsgHeader.Fill(bsn_common.TMsgType(vTGateServerMsgType), vTMsgLen)
	return this
}
Exemple #20
0
func (this *SServerUserGateConfig) send_CmdGate2GateConfig_GetServerConfigReq() error {
	sendMsg := &bsn_msg_gate_gateconfig.SGate2GateConfig_GetServerConfigReq{
		Vu32Id: proto.Uint32(1),
	}
	return this.SendPbMsgWithSMsgHeader(bsn_common.TMsgType(bsn_msg_gate_gateconfig.ECmdGate2GateConfig_CmdGate2GateConfig_GetServerConfigReq), sendMsg)
}
Exemple #21
0
func (this *SClientUser) TestReq() {
	sendMsg := &bsn_msg_client_gate.STestReq{
		VstrInfo: proto.String("gate test req"),
	}
	this.SendPbMsgWithSMsgHeader(bsn_common.TMsgType(bsn_msg_client_gate.ECmdGate2Client_CmdGate2Client_TestReq), sendMsg)
}
Exemple #22
0
func (this *SClientUser) Send2Client(vTClientId TClientId, byMsg []byte) error {
	vSMsg_Server2Gate_ClientMsg := new(bsn_msg.SMsg_Server2Gate_ClientMsg)
	vSMsg_Server2Gate_ClientMsg.Fill(uint16(vTClientId), byMsg)
	return this.SendMsgWithSMsgHeader(bsn_common.TMsgType(bsn_msg_gate_server.ECmdServe2Gate_CmdServer2Gate_ClientMsg), vSMsg_Server2Gate_ClientMsg.Serialize())
}
Exemple #23
0
func (this *SMsgHeaderServer2Gate) FillMsg(vTServer2GateMsgType TServer2GateMsgType, by2GateMsg, by2ClientMsg []byte) {
	this.SMsgHeader.Fill(bsn_common.TMsgType(vTServer2GateMsgType), bsn_common.TMsgLen(len(by2GateMsg)))
	this.Fill(bsn_common.TMsgLen(len(by2ClientMsg)))
}
Exemple #24
0
func NewMsgHeaderGateClient(vu8ServerType, vu8ServerId uint8, vTMsgLen bsn_common.TMsgLen) *SMsgHeaderGateClient {
	this := &SMsgHeaderGateClient{}
	vUserId := bsn_common.MakeGateUserId(vu8ServerType, vu8ServerId)
	this.SMsgHeader.Fill(bsn_common.TMsgType(vUserId), vTMsgLen)
	return this
}