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