private async void btnConnect_Click(object sender, EventArgs e) { Debug.WriteLine("Connects to server."); await _httpSignaler.Connect(); btnConnect.Enabled = false; btnDisconnect.Enabled = true; }
private void InitView() { PrepareView(); foreach (Peer peer in _signaler._peers) { peersListView.Items.Add(peer); } AccountSettings.Click += (sender, args) => Frame.Navigate(typeof(SettingsAccountPage)); ConnectionSettings.Click += (sender, args) => Frame.Navigate(typeof(SettingsConnectionPage)); DevicesSettings.Click += (sender, args) => Frame.Navigate(typeof(SettingsDevicesPage)); DebugSettings.Click += (sender, args) => Frame.Navigate(typeof(SettingsDebugPage)); ConnectPeer.Click += async(sender, args) => { await _signaler.Connect(_account.ServiceUri); ConnectPeer.IsEnabled = false; DisconnectPeer.IsEnabled = true; }; DisconnectPeer.Click += async(sender, args) => { await _signaler.SignOut(); peersListView.Items.Clear(); ConnectPeer.IsEnabled = true; DisconnectPeer.IsEnabled = false; }; CallRemotePeer.Click += (sender, args) => { if (peersListView.SelectedIndex == -1) { new MessageDialog("Please select a peer.").ShowAsync(); return; } Peer remotePeer = peersListView.SelectedItem as Peer; if (remotePeer == null) { return; } Task.Run(async() => { _call.PeerId = remotePeer.Id; CallInfo callInfo = (CallInfo)await _call.PlaceCallAsync(null); }); }; }
/// <summary> /// Logs in local peer to server. /// </summary> /// <returns></returns> public async Task LogInToServer() { Debug.WriteLine("Connects to server."); await _signaler.Connect(Account.ServiceUri); }
private void InitView() { listMessages.ItemsSource = _messages; IsSendReady = false; btnSend.IsEnabled = false; ConnectPeer.Click += async(sender, args) => { Debug.WriteLine("Connects to server."); await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => await _httpSignaler.Connect()); ConnectPeer.IsEnabled = false; //ConnectPeer.BackgroundColor = Color.DarkGray; DisconnectPeer.IsEnabled = true; //DisconnectPeer.BackgroundColor = Color.Gray; }; DisconnectPeer.Click += async(sender, args) => { Debug.WriteLine("Disconnects from server."); peersListView.Items.Clear(); await _httpSignaler.SignOut(); DisconnectPeer.IsEnabled = false; //DisconnectPeer.BackgroundColor = Color.DarkGray; ConnectPeer.IsEnabled = true; //ConnectPeer.BackgroundColor = Color.Gray; }; btnChat.Click += async(sender, args) => { if (peersListView.SelectedIndex == -1) { await new MessageDialog("Please select a peer.").ShowAsync(); return; } Peer remotePeer = peersListView.SelectedItem as Peer; if (remotePeer == null) { return; } _httpSignaler.SendToPeer(remotePeer.Id, "OpenDataChannel"); await SetupPeer(remotePeer, true); }; btnSend.Click += (sender, args) => { if (!IsSendReady) { Debug.WriteLine("Please wait, connecting..."); return; } else { Message message = new Message(OrtcController.LocalPeer, DateTime.Now, txtMessage.Text); _messages.Add(message); txtMessage.Text = string.Empty; OnSendMessageToRemotePeer(message); } }; }
async partial void ConnectButtonClicked(NSObject sender) { await HttpSignaler.Connect(); }
private void InitView() { peersListView.ItemsSource = HttpSignaler._peers; // Page structure Content = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.Center, Children = { new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.CenterAndExpand, Children = { ConnectPeer, DisconnectPeer } }, peersListView, btnChat } }; ConnectPeer.Clicked += async(sender, args) => { Debug.WriteLine("Connects to server."); await _httpSignaler.Connect(); ConnectPeer.IsEnabled = false; ConnectPeer.BackgroundColor = Color.DarkGray; DisconnectPeer.IsEnabled = true; DisconnectPeer.BackgroundColor = Color.Gray; }; DisconnectPeer.Clicked += async(sender, args) => { Debug.WriteLine("Disconnects from server."); await _httpSignaler.SignOut(); DisconnectPeer.IsEnabled = false; DisconnectPeer.BackgroundColor = Color.DarkGray; ConnectPeer.IsEnabled = true; ConnectPeer.BackgroundColor = Color.Gray; }; btnChat.Clicked += async(sender, args) => { Peer remotePeer = peersListView.SelectedItem as Peer; if (remotePeer == null) { return; } _httpSignaler.SendToPeer(remotePeer.Id, "OpenDataChannel"); await SetupPeer(remotePeer, true); }; }