public void MergeFrom(ClaimCodenameResponse other)
 {
     if (other == null)
     {
         return;
     }
     if (other.Codename.Length != 0)
     {
         Codename = other.Codename;
     }
     if (other.UserMessage.Length != 0)
     {
         UserMessage = other.UserMessage;
     }
     if (other.IsAssignable != false)
     {
         IsAssignable = other.IsAssignable;
     }
     if (other.Status != 0)
     {
         Status = other.Status;
     }
     if (other.updatedPlayer_ != null)
     {
         if (updatedPlayer_ == null)
         {
             updatedPlayer_ = new global::POGOProtos.Data.PlayerData();
         }
         UpdatedPlayer.MergeFrom(other.UpdatedPlayer);
     }
     suggestedCodenames_.Add(other.suggestedCodenames_);
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
        public override int GetHashCode()
        {
            int hash = 1;

            if (Codename.Length != 0)
            {
                hash ^= Codename.GetHashCode();
            }
            if (UserMessage.Length != 0)
            {
                hash ^= UserMessage.GetHashCode();
            }
            if (IsAssignable != false)
            {
                hash ^= IsAssignable.GetHashCode();
            }
            if (Status != 0)
            {
                hash ^= Status.GetHashCode();
            }
            if (updatedPlayer_ != null)
            {
                hash ^= UpdatedPlayer.GetHashCode();
            }
            hash ^= suggestedCodenames_.GetHashCode();
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
    private void OnData(DataStreamReader stream)
    {
        NativeArray <byte> message = new NativeArray <byte>(stream.Length, Allocator.Temp);

        stream.ReadBytes(message);
        string returnData = Encoding.ASCII.GetString(message.ToArray());

        NetworkHeader header = new NetworkHeader();

        header = JsonUtility.FromJson <NetworkHeader>(returnData);

        switch (header.cmd)
        {
        case Commands.NEW_CLIENT:
        {
            Debug.Log("New client");
            NewPlayer np = JsonUtility.FromJson <NewPlayer>(returnData);
            Debug.Log("NEW_CLIENT: " + np.player.ToString());
            SpawnPlayers(np.player);
            break;
        }

        case Commands.UPDATE:
        {
            UpdatedPlayer up = JsonUtility.FromJson <UpdatedPlayer>(returnData);
            UpdatePlayers(up.update);
            break;
        }

        case Commands.CLIENT_DROPPED:
        {
            DisconnectedPlayer dp = JsonUtility.FromJson <DisconnectedPlayer>(returnData);
            DestroyPlayers(dp.disconnect);
            Debug.Log("Client dropped");
            break;
        }

        case Commands.CLIENT_LIST:
        {
            ConnectedPlayer cp = JsonUtility.FromJson <ConnectedPlayer>(returnData);
            SpawnPlayers(cp.connect);
            Debug.Log("Client list");
            break;
        }

        case Commands.OWN_ID:
        {
            NewPlayer p = JsonUtility.FromJson <NewPlayer>(returnData);
            myID = p.player.id;
            SpawnPlayers(p.player);
            Debug.Log("OWN_ID: " + myID);
            break;
        }

        default:
            Debug.Log("Error");
            break;
        }
    }
Example #4
0
    private void OnData(DataStreamReader stream)
    {
        NativeArray <byte> message = new NativeArray <byte>(stream.Length, Allocator.Temp);

        stream.ReadBytes(message);
        string returnData = Encoding.ASCII.GetString(message.ToArray());

        NetworkHeader header = new NetworkHeader();

        try
        {
            header = JsonUtility.FromJson <NetworkHeader>(returnData);
        }
        catch (System.ArgumentException e)
        {
            Debug.LogError(e.ToString() + "\nFailed To Load. Disconnect");
            Disconnect();
            return;
        }

        try
        {
            switch (header.cmd)
            {
            case Commands.NEW_CLIENT:
            {
                Debug.Log("A Client Appears!");
                NewPlayer np = JsonUtility.FromJson <NewPlayer>(returnData);
                Debug.Log(np.player.ToString());
                SpawnPlayers(np.player);
                break;
            }

            case Commands.UPDATE:
            {
                UpdatedPlayer up = JsonUtility.FromJson <UpdatedPlayer>(returnData);
                UpdatePlayers(up.update);
                break;
            }

            case Commands.CLIENT_DROPPED:
            {
                DisconnectedPlayer dp = JsonUtility.FromJson <DisconnectedPlayer>(returnData);
                DestroyPlayers(dp.disconnect);
                Debug.Log("A Client Disappers!");
                break;
            }

            case Commands.CLIENT_LIST:
            {
                ConnectedPlayer cp = JsonUtility.FromJson <ConnectedPlayer>(returnData);
                SpawnPlayers(cp.connect);
                Debug.Log("Client_List");
                break;
            }

            case Commands.OWN_ID:
            {
                NewPlayer p = JsonUtility.FromJson <NewPlayer>(returnData);
                myID = p.player.id;
                SpawnPlayers(p.player);
                Debug.Log("PlayerID");
                break;
            }

            default:
                Debug.Log("Error!");
                break;
            }
        }
        catch (System.Exception e)
        {
            Debug.LogError(e.ToString() + "\nMessage Contents Failed to Load. Disconnect");
            Disconnect();
            return;
        }
    }