public override void Send(byte[] byteData, UInt32 dwLen) { byte[] pData = new byte[dwLen + GetDataHeader().GetHeaderLength()]; FxNet.NetStream oNetStream = new NetStream(NetStream.ENetStreamType.ENetStreamType_Write, pData, (UInt32)pData.Length); UInt32 dwHeaderLen = 0; byte[] pDataHeader = GetDataHeader().BuildSendPkgHeader(ref dwHeaderLen, dwLen); oNetStream.WriteData(pDataHeader, GetDataHeader().GetHeaderLength()); oNetStream.WriteData(byteData, dwLen); m_pSendBuffer.PushData(pData, (UInt32)pData.Length); }
public void OnPlayerRequestGameTest(byte[] pBuf) { GameProto.PlayerRequestGameTest oTest = GameProto.PlayerRequestGameTest.Parser.ParseFrom(pBuf); if (oTest == null) { H5Helper.H5LogStr("OnTest error parse"); return; } H5Helper.H5LogStr(oTest.SzTest.ToString()); oTest.SzTest = String.Format("{0}, {1}, {2}, {3}, {4}, {5}", "sessionobject.cs", 106, "SessionObject::OnRecv", dw1++, ToString(), DateTime.Now.ToLocalTime().ToString()); byte[] pData = new byte[1024]; FxNet.NetStream pStream = new FxNet.NetStream(FxNet.NetStream.ENetStreamType.ENetStreamType_Write, pData, 1024); pStream.WriteString("GameProto.PlayerRequestGameTest"); byte[] pProto = new byte[oTest.CalculateSize()]; Google.Protobuf.CodedOutputStream oStream = new Google.Protobuf.CodedOutputStream(pProto); oTest.WriteTo(oStream); pStream.WriteData(pProto, (uint)pProto.Length); m_pSession.Send(pData, 1024 - pStream.GetLeftLen()); }
public void MakeTeam() { GameProto.PlayerRequestLoginMakeTeam oTeam = new GameProto.PlayerRequestLoginMakeTeam(); byte[] pData = new byte[1024]; FxNet.NetStream pStream = new FxNet.NetStream(FxNet.NetStream.ENetStreamType.ENetStreamType_Write, pData, 1024); pStream.WriteString("GameProto.PlayerRequestLoginMakeTeam"); byte[] pProto = new byte[oTeam.CalculateSize()]; Google.Protobuf.CodedOutputStream oStream = new Google.Protobuf.CodedOutputStream(pProto); oTeam.WriteTo(oStream); pStream.WriteData(pProto, (uint)pProto.Length); m_pSession.Send(pData, 1024 - pStream.GetLeftLen()); }
public void InvitePlayer() { GameProto.PlayerRequestLoginInviteTeam oTeam = new GameProto.PlayerRequestLoginInviteTeam(); oTeam.QwPlayerId = m_qwPlayerId; byte[] pData = new byte[1024]; FxNet.NetStream pStream = new FxNet.NetStream(FxNet.NetStream.ENetStreamType.ENetStreamType_Write, pData, 1024); pStream.WriteString("GameProto.PlayerRequestLoginInviteTeam"); byte[] pProto = new byte[oTeam.CalculateSize()]; Google.Protobuf.CodedOutputStream oStream = new Google.Protobuf.CodedOutputStream(pProto); oTeam.WriteTo(oStream); pStream.WriteData(pProto, (uint)pProto.Length); H5Manager.Instance().GetLoginSession().Send(pData, 1024 - pStream.GetLeftLen()); //m_pSession.Send(pData, 1024 - pStream.GetLeftLen()); }
public void OnRoleData(string szData) { SampleDebuger.Log(szData); RoleDataRet oData = JsonUtility.FromJson <RoleDataRet>(szData); GameProto.PlayerRequestLogin oTest = new GameProto.PlayerRequestLogin(); oTest.SzToken = oData.token; oTest.QwPlayerId = oData.data.id; oTest.SzAvatar = oData.data.avatar; oTest.SzNickName = oData.data.nick_name; oTest.DwSex = oData.data.sex; oTest.DwBalance = oData.data.balance; StartCoroutine(H5Helper.SendGet(oData.data.avatar, delegate(Texture2D tex) { PlayerData.Instance().SetHeadTex(tex); }) ); PlayerData.Instance().SetPlayerId(oData.data.id); PlayerData.Instance().SetName(oData.data.nick_name); PlayerData.Instance().SetHeadImage(oData.data.avatar); PlayerData.Instance().SetSex(oData.data.sex); PlayerData.Instance().SetBalance(oData.data.balance); PlayerData.Instance().SetToken(oData.token); byte[] pData = new byte[2048]; FxNet.NetStream pStream = new FxNet.NetStream(FxNet.NetStream.ENetStreamType.ENetStreamType_Write, pData, 2048); pStream.WriteString("GameProto.PlayerRequestLogin"); byte[] pProto = new byte[oTest.CalculateSize()]; Google.Protobuf.CodedOutputStream oStream = new Google.Protobuf.CodedOutputStream(pProto); oTest.WriteTo(oStream); pStream.WriteData(pProto, (uint)pProto.Length); m_pSession.Send(pData, 2048 - pStream.GetLeftLen()); if (!string.IsNullOrEmpty(oData.game_ip)) { PlayerData.Instance().SetGameIp(oData.game_ip); PlayerData.Instance().SetGamePort((ushort)oData.game_port); } }
public void IntoInviteTeam(object pParam) { GameProto.LoginNotifyPlayerInviteTeam oInvite = pParam as GameProto.LoginNotifyPlayerInviteTeam; if (oInvite == null) { H5Helper.H5AlertString("IntoInviteTeam parse error!!!!"); return; } GameProto.PlayerRequestLoginEnterTeam oRequest = new GameProto.PlayerRequestLoginEnterTeam(); oRequest.DwTeamServerId = oInvite.DwTeamServerId; oRequest.QwTeamId = oInvite.QwTeamId; byte[] pData = new byte[1024]; FxNet.NetStream pStream = new FxNet.NetStream(FxNet.NetStream.ENetStreamType.ENetStreamType_Write, pData, 1024); pStream.WriteString("GameProto.PlayerRequestLoginEnterTeam"); byte[] pProto = new byte[oRequest.CalculateSize()]; Google.Protobuf.CodedOutputStream oStream = new Google.Protobuf.CodedOutputStream(pProto); oRequest.WriteTo(oStream); pStream.WriteData(pProto, (uint)pProto.Length); m_pSession.Send(pData, 1024 - pStream.GetLeftLen()); }
public void OnRoleData(string szData) { Debug.Log(szData); RoleDataRet oData = JsonUtility.FromJson <RoleDataRet>(szData); GameProto.PlayerRequestLogin oTest = new GameProto.PlayerRequestLogin(); oTest.SzToken = oData.token; oTest.QwPlayerId = oData.data.id; oTest.SzAvatar = oData.data.avatar; oTest.SzNickName = oData.data.nick_name; oTest.DwSex = oData.data.sex; oTest.DwBalance = oData.data.balance; byte[] pData = new byte[2048]; FxNet.NetStream pStream = new FxNet.NetStream(FxNet.NetStream.ENetStreamType.ENetStreamType_Write, pData, 2048); pStream.WriteString("GameProto.PlayerRequestLogin"); byte[] pProto = new byte[oTest.CalculateSize()]; Google.Protobuf.CodedOutputStream oStream = new Google.Protobuf.CodedOutputStream(pProto); oTest.WriteTo(oStream); pStream.WriteData(pProto, (uint)pProto.Length); m_pSession.Send(pData, 2048 - pStream.GetLeftLen()); }
public void NotIntoInviteTeam(object pParam) { GameProto.LoginNotifyPlayerInviteTeam oInvite = pParam as GameProto.LoginNotifyPlayerInviteTeam; if (oInvite == null) { SampleDebuger.LogError("NotIntoInviteTeam parse error!!!!"); return; } GameProto.PlayerRequestLoginRefuseEnterTeam oRequest = new GameProto.PlayerRequestLoginRefuseEnterTeam(); oRequest.QwPlayerId = oInvite.QwPlayerId; oRequest.SzReason = "refused!!!"; byte[] pData = new byte[1024]; FxNet.NetStream pStream = new FxNet.NetStream(FxNet.NetStream.ENetStreamType.ENetStreamType_Write, pData, 1024); pStream.WriteString("GameProto.PlayerRequestLoginRefuseEnterTeam"); byte[] pProto = new byte[oRequest.CalculateSize()]; Google.Protobuf.CodedOutputStream oStream = new Google.Protobuf.CodedOutputStream(pProto); oRequest.WriteTo(oStream); pStream.WriteData(pProto, (uint)pProto.Length); m_pSession.Send(pData, 1024 - pStream.GetLeftLen()); }