public static JSONObject GetField(this SocketIOEvent e, string field)
    {
        if (!e.HasPayload())
        {
            return(null);
        }
        var payload = e.GetPayload();

        return(payload.HasField(field) ? payload.GetField(field) : null);
    }
Example #2
0
    public void OnPlayerAdded(SocketIOEvent e)
    {
        Assert.That(e.HasPayload());

        var playerId = e.GetString(SOCKET_DATA_FIELDS.PlayerId);

        if (GetRemotePlayer(playerId) != null)
        {
            return;
        }

        AddPlayerFromPayload(e.GetPayload());
    }
    public static float?GetFloat(this SocketIOEvent e, string field)
    {
        if (!e.HasPayload())
        {
            return(null);
        }
        var payload = e.GetPayload();

        if (!payload.HasField(field))
        {
            return(null);
        }

        var jobj = payload.GetField(field);

        return(jobj.IsNumber ? jobj.n : float.Parse(jobj.str));
    }
Example #4
0
    public void OnOtherPlayersReceived(SocketIOEvent e)
    {
        var data = e.GetPayload();

        unityDebugProxy.Log($"{e.name} - {data}");

        var players = data.list;

        foreach (var player in players)
        {
            var playerId = player.GetField(SOCKET_DATA_FIELDS.PlayerId).str;
            if (!state.RemotePlayerExists(playerId))
            {
                AddPlayerFromPayload(player);
            }

            unityDebugProxy.Log($"Added remote player {player}");
        }
    }
 public static bool HasField(this SocketIOEvent e, string field)
 {
     return(e.HasPayload() && e.GetPayload().HasField(field));
 }