Example #1
0
 private void OnAccept(ClientAcceptedEventArgs e)
 {
     foreach (EventListener el in Plugins)
     {
         ServerListener sl = (ServerListener)el.Listener;
         if (el.Event == Event.ServerAccept)
             sl.OnAccept(e);
     }
 }
Example #2
0
        private void Accept_Process(SocketAsyncEventArgs e)
        {
            if (OnBeforeAccept(e.AcceptSocket))
            {
                Interlocked.Increment(ref NextSessionId);
                Client c = new Client(NextSessionId, this, e.AcceptSocket);
                //Event
                ClientAcceptedEventArgs args = new ClientAcceptedEventArgs(this, c);
                PluginManager.CallEvent(Event.ServerAccept, args);
                //Do not check for EventCanceled because that could make this unstable.
                //End Event

                c.Start();
                
                AddClient(c);
                Logger.Log(LogLevel.Info, "Clients online: {0}", Clients.Count);
                                
                Logger.Log(LogLevel.Info, "Starting client");
                OnJoined(c);
            }
            else
            {
                if (e.AcceptSocket.Connected)
                    e.AcceptSocket.Shutdown(SocketShutdown.Both);
                e.AcceptSocket.Close();
            }
            _AcceptEventArgs.AcceptSocket = null;
            Interlocked.Exchange(ref _asyncAccepts, 0);
            NetworkSignal.Set();
        }
Example #3
0
 public virtual void OnAccept(ClientAcceptedEventArgs e) { }