private void ServerOnConnected(object sender, ServerConnectedEventArgs e) { childLifetimeScope = parentLifetimeScope.BeginLifetimeScope(builder => { builder.RegisterInstance(new CommunicationSettings(e.Heartbeat)).AsSelf(); builder.RegisterInstance(e.Protocol).As <ICommunicationProtocol>(); builder.RegisterType <CommandLineMediator>().AsSelf().AutoActivate(); builder.RegisterType <InterProcessUpdateReceiver>().AsSelf().AutoActivate(); }); }
public async Task StartAsync() { _server.Start(); _isServerWorking = true; while (_isServerWorking) { _client = await _server.AcceptTcpClientAsync(); ServerConnectedEventArgs args = new ServerConnectedEventArgs(_client); OnServerConnected(args); ThreadPool.QueueUserWorkItem(ConnectClientsThredProc, _client); } }
private void Server_Connected(object sender, ServerConnectedEventArgs e) { string clientName = e.Context.ClientKey; e.Context.Tag = clientName; ClientState newState = new ClientState { Context = e.Context, IsRegistered = false, LastSeen = DateTime.UtcNow, }; lock (ClientsByNameLock) ClientsByName.Add(clientName, newState); }
private void Server_Disconnected(object sender, ServerConnectedEventArgs e) { string clientName = (string)e.Context.Tag; if (string.IsNullOrEmpty(clientName)) { return; } lock (ClientsByNameLock) { if (ClientsByName.ContainsKey(clientName)) { ClientsByName.Remove(clientName); } } }
/// <summary> /// Handles a server connecting. /// </summary> /// <param name="sender">The <see cref="ServerManager"/></param> /// <param name="e">The event args.</param> private void ServerConnected(object sender, ServerConnectedEventArgs e, int serverID) { Interlocked.Increment(ref serverConnectedEvents); }
private void OnServerConnected(ServerConnectedEventArgs e) { ServerConnectedEvent(this, e); }
protected virtual void OnDisconnected(ServerConnectedEventArgs e) { logger.Debug("DISCONNECTED"); InvokeDelegate(Disconnected, e); }
protected virtual void OnConnected(ServerConnectedEventArgs e) { logger.Debug("CONNECTION FROM {0}", e.Context.ClientKey); InvokeDelegate(Connected, e); }
private static void HandleServerConnected(object sender, ServerConnectedEventArgs e) { Console.WriteLine($"{DateTime.Now} - Connected to: {e.Server}:{e.Port}{Environment.NewLine}"); }
private void HandleServerConnected(object sender, ServerConnectedEventArgs e) { LogListBox.Items.Add(string.Format("{0} - Podłączono do serwera: {1}:{2}", DateTime.Now, e.ServerIp, e.ServerPort)); }
void Server_Connected(object sender, ServerConnectedEventArgs e) { AppendToHistory("CLIENT CONNECTED: {0}", e.Context.ClientKey); }