Ejemplo n.º 1
0
 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();
     });
 }
Ejemplo n.º 2
0
    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);
        }
    }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
                }
            }
        }
Ejemplo n.º 5
0
 /// <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);
 }
Ejemplo n.º 6
0
 private void OnServerConnected(ServerConnectedEventArgs e)
 {
     ServerConnectedEvent(this, e);
 }
Ejemplo n.º 7
0
 protected virtual void OnDisconnected(ServerConnectedEventArgs e)
 {
     logger.Debug("DISCONNECTED");
     InvokeDelegate(Disconnected, e);
 }
Ejemplo n.º 8
0
 protected virtual void OnConnected(ServerConnectedEventArgs e)
 {
     logger.Debug("CONNECTION FROM {0}", e.Context.ClientKey);
     InvokeDelegate(Connected, e);
 }
Ejemplo n.º 9
0
 private static void HandleServerConnected(object sender, ServerConnectedEventArgs e)
 {
     Console.WriteLine($"{DateTime.Now} - Connected to: {e.Server}:{e.Port}{Environment.NewLine}");
 }
Ejemplo n.º 10
0
 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));
 }
Ejemplo n.º 11
0
 void Server_Connected(object sender, ServerConnectedEventArgs e)
 {
     AppendToHistory("CLIENT CONNECTED: {0}", e.Context.ClientKey);
 }