Esempio n. 1
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);
        }
    }
Esempio n. 2
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());
    }