private void OnSessionConnected(NetworkConnection connection) { this.IsServerConnected = true; LogWriteLine("Server connected."); SessionConnected?.Invoke(connection); }
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(); } } }
internal static void RaiseSessionConnectedEvent([NotNull] Player player) { if (player == null) { throw new ArgumentNullException(nameof(player)); } SessionConnected?.Invoke(null, new PlayerEventArgs(player)); }
/// <summary> /// Raise the <see cref="SessionConnected"/> event. /// </summary> /// <param name="session">The new session.</param> protected void InvokeSessionConnected(IEtpSession session) { SessionConnected?.Invoke(this, session); }