Exemplo n.º 1
0
        private void OnCreateChannel()
        {
            if (!RoomsID.Contains(NewRoomID))
            {
                var createFormat = new
                {
                    sessionId      = SessionID,
                    username       = Username,
                    conversationId = NewRoomID
                };
                socket.Emit("CreateConverstation", JsonConvert.SerializeObject(createFormat));
                // TEST ONLY
                RoomsID.Add(NewRoomID);

                socket.On("CreatedCoversation", (data) => {
                    var _roomIDformat = new
                    {
                        conversationId = ""
                    };
                    var _roomID = JsonConvert.DeserializeAnonymousType(data.ToString(), _roomIDformat);
                    RoomsID.Add(_roomID.conversationId);
                    RoomID = _roomID.conversationId;
                });
            }
            RoomID = NewRoomID;
        }
Exemplo n.º 2
0
 public void Connect(string Localization)
 {
     if (RoomsID.Contains("General"))
     {
         RoomsID.Add("General");
     }
     RoomID = "General";
     JoinChannel(Localization);
     socket.On("MessageSent", (data) =>
     {
         var messageFormat = new
         {
             date           = "",
             username       = "",
             message        = "",
             conversationId = ""
         };
         Console.WriteLine("Message recieved : " + data.ToString());
         var message = JsonConvert.DeserializeAnonymousType(data.ToString(), messageFormat);
         ReceiveMessage(message.date, message.username, message.message);
     });
 }