Exemplo n.º 1
0
        private void OnSessionConnected(NetworkConnection connection)
        {
            this.IsServerConnected = true;
            LogWriteLine("Server connected.");

            SessionConnected?.Invoke(connection);
        }
Exemplo n.º 2
0
        public async void StartHost()
        {
            if (Main == null)
            {
                throw new InvalidOperationException(" 'Main' was null!");
            }

            server.Start();

            while (true)
            {
                var socket = await server.AcceptSocketAsync();

                var session = new TelnetSession(this, socket);
                _sessions.Add(session.ConnectionId, session);

                var e = new SessionEventArgs(session);  //todo: this client event can block the whole server
                SessionConnected?.Invoke(this, e);

                if (!e.RefuseConnection)
                {
                    session.Run();
                }
                else
                {
                    session.Kick();
                }
            }
        }
Exemplo n.º 3
0
 internal static void RaiseSessionConnectedEvent([NotNull] Player player)
 {
     if (player == null)
     {
         throw new ArgumentNullException(nameof(player));
     }
     SessionConnected?.Invoke(null, new PlayerEventArgs(player));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Raise the <see cref="SessionConnected"/> event.
 /// </summary>
 /// <param name="session">The new session.</param>
 protected void InvokeSessionConnected(IEtpSession session)
 {
     SessionConnected?.Invoke(this, session);
 }