Exemplo n.º 1
0
    public static BasicPeerContent Deserialize(string json)
    {
        BasicPeerContent basic = JsonUtility.FromJson <BasicPeerContent>(json);

        switch (basic.Type)
        {
        case PeerMessageType.ASSIGN:
            return(JsonUtility.FromJson <AssignMessage>(json));
        }

        return(basic);
    }
Exemplo n.º 2
0
    // public functions

    // WEB-TO-UNITY functions
    public void message(string strmessage)
    {
        string[] split = strmessage.Split('#');

        BasicPeerContent content = BasicPeerContent.Deserialize(split[3]);

        PeerMessage msg = new PeerMessage()
        {
            Channel   = split[0],
            Peer      = split[1], // FROM
            Timestamp = DateTime.Parse(split[2]),
            Content   = content,
        };

        onMessage(msg);
        Debug.Log(string.Format("[{0}] message channel: {1} peer: {2}", msg.Timestamp.ToString(), msg.Channel, msg.Peer));
    }
Exemplo n.º 3
0
 public static void Broadcast(BasicPeerContent message, string[] channels)
 {
     UTWBroadcast(message.Serialize(), channels);
 }
Exemplo n.º 4
0
 public static void Send(string to, BasicPeerContent message, string[] channels)
 {
     UTWSend(to, message.Serialize(), channels);
 }