private void OnAccept(ClientAcceptedEventArgs e) { foreach (EventListener el in Plugins) { ServerListener sl = (ServerListener)el.Listener; if (el.Event == Event.SERVER_ACCEPT) sl.OnAccept(e); } }
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(Chraft.Logger.LogLevel.Info, "Clients online: {0}", Clients.Count); Logger.Log(Chraft.Logger.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(); }
private void AcceptClient() { TcpClient tcp = Tcp.AcceptTcpClient(); if (OnBeforeAccept(tcp)) { Client c = new Client(this, AllocateEntity(), tcp); //Event ClientAcceptedEventArgs e = new ClientAcceptedEventArgs(this, c); PluginManager.CallEvent(Event.SERVER_ACCEPT, e); //Do not check for EventCanceled because that could make this unstable. //End Event lock (Clients) Clients.Add(c.EntityId, c); AddEntity(c); c.Start(); OnJoined(c); } else { tcp.Close(); } }
public virtual void OnAccept(ClientAcceptedEventArgs e) { }
private void Accept_Process(SocketAsyncEventArgs e) { if (OnBeforeAccept(e.AcceptSocket)) { Client c = new Client(e.AcceptSocket, new Player(this, AllocateEntity())); //Event ClientAcceptedEventArgs args = new ClientAcceptedEventArgs(this, c); PluginManager.CallEvent(Event.SERVER_ACCEPT, args); //Do not check for EventCanceled because that could make this unstable. //End Event lock (Clients) { AddClient(c); Logger.Log(Chraft.Logger.LogLevel.Info, "Clients online: {0}", Clients.Count); } AddEntity(c.Owner); c.Start(); Logger.Log(Chraft.Logger.LogLevel.Info, "Starting client"); OnJoined(c); } else { e.AcceptSocket.Close(); } Interlocked.Exchange(ref _AsyncAccepts, 0); NetworkSignal.Set(); }