Esempio n. 1
0
 private void OnMessage(string mes, string userID)
 {
     if (mes.Equals(""))
     {
         OutRoomVoid();
         //If don't have this line, user Second will not be Stop HubConnect,
         //But if have this line, Will be disconnected, before done line 104 (await ChatHub.Invoke(chat..)
         if (!IGetOut)
         {
             if (HubConnect.State == ConnectionState.Connected)
             {
                 HubConnect.Stop();
             }
         }
     }
     else
     {
         Device.BeginInvokeOnMainThread(() => {
             var msg = new Message()
             {
                 Content = mes, IsMine = userID == HubConnect.ConnectionId
             };
             CollectionMessage.Add(msg);
         });
     }
 }
Esempio n. 2
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            await HubConnect.Start();

            GetInARoomVoid();
            if (!IsReady)
            {
                UpdateStatus("Đã vào phòng");
            }
        }
Esempio n. 3
0
 private async void btn_onGetOutClicked(object sender, EventArgs e)
 {
     IGetOut           = true;
     OutRoom.IsEnabled = false;
     try
     {
         await ChatHub.Invoke("Chat", "");
     }
     catch { }
     //Wait for get Message "GetOut", then Stop Connect the HubConnect.
     //If, HubConnect.Stop() in line 130, Will be crash, because the asyncho, (stop Hub, still...)
     if (HubConnect.State == ConnectionState.Connected)
     {
         HubConnect.Stop();
     }
 }