public PeerContextData(IPeerEntry peerEntry, Button peerButton) : this() { PeerEntry = peerEntry; PeerButton = peerButton; }
private void Window_Loaded(object sender, RoutedEventArgs e) { InputNameDialog nameDialog = new InputNameDialog(); if (nameDialog.ShowDialog() == true) { _name = nameDialog.ResponseText; Title = _name; } else { Environment.Exit(-1); } #region Adress init var addresses = Dns.GetHostAddresses(Dns.GetHostName()); foreach (IPAddress address in Dns.GetHostAddresses(Dns.GetHostName())) { if (address.AddressFamily == AddressFamily.InterNetwork) { _port = GetAvailablePort(); if (_port == default(int)) { var msg = "Cannot find available port. Application will be shut down."; _logger.Fatal(msg); MessageBox.Show(this, msg, "Networking Error", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(-1); } _serviceUrl = string.Format("net.tcp://{0}:{1}/P2PService", address, _port); _logger.Info($"Service URL: {_serviceUrl}"); break; } } if (string.IsNullOrEmpty(_serviceUrl)) { var msg = "Invalid service address. Application will be shut down."; _logger.Fatal(msg); MessageBox.Show(this, msg, "Networking Error", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(-1); } #endregion try { StartWcfService(); } catch (AddressAlreadyInUseException ex) { var msg = "Host address is already in use. Application will be shut down."; _logger.Fatal(ex, ex.Message); MessageBox.Show(this, msg, "WCF Error", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(-1); } CreatePeer(); InitPeerResolver(); _user = new PeerEntry(_localService, _serviceUrl); _uiSyncContex = SynchronizationContext.Current.CreateCopy(); _refreshPeerTimer = new Timer(TimerCallBack, new object(), TimeSpan.FromMilliseconds(PEERLIST_REFRESH_DELAY_MS), TimeSpan.FromMilliseconds(AppSettings.PeerListRefreshMs)); #region key downs MessageTextBox.KeyDown += new KeyEventHandler(MessageKeyDown); #endregion }
public Message(IPeerEntry from, string content) { From = from as PeerEntry; Content = content; }
public MessageOverNet(IPeerEntry peerEntry, string content) : this(peerEntry.DisplayedName, content) { }