private void StopGablarski() { justStarting = false; this.gablarski.Users.UserJoined -= OnUserLoggedIn; this.gablarski.Users.UserDisconnected -= OnUserDisconnected; this.gablarski.Disconnect(); this.gablarski = null; }
/// <summary> /// Creates a new instance of <see cref="NotificationHandler"/>. /// </summary> /// <param name="client"></param> public NotificationHandler(GablarskiClient client) { this.client = client; this.client.Disconnected += OnClientDisconnected; this.client.Users.UserJoined += OnUserJoined; this.client.Users.UserDisconnected += OnUserDisconnected; this.client.Users.UserChangedChannel += OnUserChangedChannel; this.client.Users.UserKickedFromChannel += OnUserKickedFromChannel; this.client.Users.UserKickedFromServer += OnUserKickedFromServer; }
public RegisterForm(GablarskiClient client) { if (client == null) throw new ArgumentNullException ("client"); this.client = client; this.client.Disconnected += OnDisconnected; Icon = Resources.UserAddImage.ToIcon(); InitializeComponent(); }
private void StartGablarski() { this.gablarski = new GablarskiClient(new NetworkClientConnection()); this.gablarski.Connected += OnConnected; this.gablarski.ConnectionRejected += OnConnectionRejected; this.gablarski.Disconnected += OnDisconnected; this.gablarski.Users.UserJoined += OnUserLoggedIn; this.gablarski.Users.UserDisconnected += OnUserDisconnected; this.gablarski.Connect(ConfigurationManager.AppSettings["gbServer"], Int32.Parse(ConfigurationManager.AppSettings["gbPort"])); }
public RegisterForm(GablarskiClient client) { if (client == null) { throw new ArgumentNullException("client"); } this.client = client; this.client.Disconnected += OnDisconnected; Icon = Resources.UserAddImage.ToIcon(); InitializeComponent(); }
private async void QueryNewServer(bool updatingPort) { int port = (int)this.inPort.Value; if (String.IsNullOrWhiteSpace(this.inServer.Text)) { return; } if (port < IPEndPoint.MinPort || port > IPEndPoint.MaxPort) { return; } this.serverStatus.Image = serverQueryImage; QueryResults results = null; bool timedOut = false; try { results = await GablarskiClient.QueryAsync(Program.Key.Result, new Target (this.inServer.Text, port), TimeSpan.FromSeconds(10)); } catch (OperationCanceledException) { timedOut = true; } bool last = this.lastWasPort; if (last && !updatingPort) { return; } if (!timedOut) { if (results == null || results.ServerInfo == null) { return; } if (String.IsNullOrWhiteSpace(this.inName.Text)) { this.inName.Text = results.ServerInfo.Name; } this.serverStatus.Image = serverOkImage; } else { SetStatusImage(serverConnectErrorImage); } }
private void LoadServerEntries() { this.servers.BeginUpdate(); this.servers.Items.Clear(); //GablarskiClient.FindLocalServers (0, DisplayLocalServer, () => !(this.IsDisposed || !this.Visible)); this.servers.Groups.Add("local", "Local Servers"); var saved = this.servers.Groups.Add("dbentries", "Saved Servers"); foreach (var entry in Servers.GetEntries()) { var li = this.servers.Items.Add(entry.Name); li.Tag = entry; li.ImageKey = "serverQuery"; saved.Items.Add(li); GablarskiClient.QueryAsync(Program.Key.Result, new Target(entry.Host, entry.Port), TimeSpan.FromSeconds(10)).ContinueWith(t => { if (IsDisposed || Disposing || this.closing) { return; } if (t.IsCanceled) { UpdateImage(li, "serverConnectError"); return; } UpdateImage(li, "server"); var results = t.Result; li.ToolTipText = String.Format("{0}{1}Users: {2}", results.ServerInfo.Description, Environment.NewLine, results.Users.Count()); }, TaskScheduler.FromCurrentSynchronizationContext()); } this.servers.EndUpdate(); }