示例#1
0
    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());
    }
示例#2
0
文件: DataHeader.cs 项目: lxlyh/FxLib
        public override byte[] BuildSendPkgHeader(ref UInt32 dwHeaderLen, UInt32 dwDataLen)
        {
            NetStream oNetStream = new NetStream(NetStream.ENetStreamType.ENetStreamType_Write, m_dataSendBuffer, 8);

            oNetStream.WriteInt(dwDataLen);
            oNetStream.WriteInt(s_dwMagic);
            dwHeaderLen = s_dwHeaderLen;
            return(m_dataSendBuffer);
        }
示例#3
0
        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);
        }
示例#4
0
    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());
    }
示例#5
0
文件: DataHeader.cs 项目: lxlyh/FxLib
        public override Int32 __CheckPkgHeader(byte[] pBuf)
        {
            NetStream oNetStream = new NetStream(NetStream.ENetStreamType.ENetStreamType_Read, pBuf, s_dwHeaderLen);
            UInt32    dwLength   = 0;

            oNetStream.ReadInt(ref dwLength);
            UInt32 dwMagic = 0;

            oNetStream.ReadInt(ref dwMagic);
            if (dwMagic != s_dwMagic)
            {
                return(-1);
            }
            return((Int32)(s_dwHeaderLen + dwLength));
        }
示例#6
0
    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());
    }
示例#7
0
    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);
        }
    }
示例#8
0
    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());
    }
示例#9
0
    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());
    }
示例#10
0
    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());
    }