예제 #1
0
 public void updateLatestMessageDict(wsGetMessageData data)
 {
     if (!latestMessageDict.ContainsKey(data.user))
     {
         latestMessageDict.Add(data.user, data);
     }
     else
     {
         latestMessageDict[data.user] = data;
     }
 }
예제 #2
0
    public void onMessage(object sender, MessageEventArgs e)
    {
        //Debug.Log("WebSocket Message Data: " + e.Data);

        wsGetMessageData msgData = JsonUtility.FromJson <wsGetMessageData>(e.Data);

        if (msgData.type == "message")
        {
            updateLatestMessageDict(msgData);
        }

        Debug.Log(msgData.text + " from " + msgData.user + " Type: " + msgData.type);
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        if (WebSocketConnectionViaSlack.instance.latestMessageDict.ContainsKey(userID))
        {
            wsGetMessageData data = WebSocketConnectionViaSlack.instance.latestMessageDict[userID];

            if (currentTS == null)
            {
                currentTS = data.ts;
            }
            else if (!currentTS.Equals(data.ts))
            {
                text.text = data.text;
            }
        }
    }
예제 #4
0
    void Websocket_MessageReceived(MessageWebSocket sender, MessageWebSocketMessageReceivedEventArgs args)
    {
        //if (OnMessaged != null)
        //{
        var reader = args.GetDataReader();

        reader.UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf8;

        string readStr = reader.ReadString(reader.UnconsumedBufferLength);

        Debug.Log(readStr);

        wsGetMessageData msgData = JsonUtility.FromJson <wsGetMessageData>(readStr);

        Debug.Log(msgData.text + " from " + msgData.user + " Type: " + msgData.type);

        if (msgData.type == "message")
        {
            updateLatestMessageDict(msgData);
        }

        //}
    }