Пример #1
0
        private async void pageLoaded(object sender, RoutedEventArgs e)
        {
            double h = height * 0.8 - 60;

            lvChat.Height            = h;
            userLogin                = session.getUserLogin();
            param                    = session.getChatPageParams();
            txtNamaUserPenerima.Text = param.nama_user_penerima;
            loadChat();
            connection = new HubConnectionBuilder()
                         .WithUrl("https://serversignalr20200907155700.azurewebsites.net/chathub")
                         .WithAutomaticReconnect()
                         .Build();

            connection.On <int, int, int, string, string, bool>("SendMessage", async(id_chat, id_user_pengirim, id_user_penerima, isi_chat, waktu_chat, isSender) =>
            {
                isSender = id_user_pengirim == userLogin.id_user ? true : false;
                listChat.Add(new Chat(id_chat, id_user_pengirim, id_user_penerima, isi_chat, waktu_chat, isSender));
                lvChat.ScrollIntoView(listChat[listChat.Count - 1]);
            });
            try
            {
                await connection.StartAsync();
            }
            catch
            {
                var messageDialog = new MessageDialog("Koneksi bermasalah");
                await messageDialog.ShowAsync();
            }
        }
Пример #2
0
 private void goToChatPage(object sender,ItemClickEventArgs e)
 {
     DisplayHeaderChat selected = (DisplayHeaderChat)e.ClickedItem;
     ChatPageParams param = new ChatPageParams(selected.id_chat, userLogin.id_user, selected.id_target_chat, selected.nama_display);
     session.setChatPageParams(param);
     this.Frame.Navigate(typeof(PersonalChatPage));
 }
Пример #3
0
        private async void goToChatPage(object sender, RoutedEventArgs e)
        {
            string responseData = await httpObject.GetRequestWithAuthorization("user/checkHeaderChat?id_user_1=" + userLogin.id_user + "&id_user_2=" + param.id_user_pelapor, session.getTokenAuthorization());

            JObject        json      = JObject.Parse(responseData);
            ChatPageParams chatParam = new ChatPageParams(Convert.ToInt32(json["id_chat"].ToString()), userLogin.id_user, param.id_user_pelapor, param.nama_user_pelapor);

            session.setChatPageParams(chatParam);
            this.Frame.Navigate(typeof(PersonalChatPage));
        }