private void AcceptCallback(IAsyncResult result) { IClientInformation userInformation = result.AsyncState as IClientInformation; ISocketClientConnection user = _SessionMembers.Find(x => x.clientInformation.UniqueID == userInformation.UniqueID); user.userSocket = _ServerSocket.EndAccept(result); ReceiveMessage(user); }
public void ClientConnect(IAsyncResult asyn) { if (_listeningSocket == null) { return; } try { ISocket clientSocket = _listeningSocket.EndAccept(asyn); if (clientSocket != null) { SocketConnection com = new SocketConnection(clientSocket); OnClientConnect?.Invoke(com); } _listeningSocket.BeginAccept(new AsyncCallback(ClientConnect), null); } catch (SocketException ex) { Diagnostics.Trace("Exception during ClientConnect: {0}", ex.Message); Stop(); } }
private void AcceptClient(IAsyncResult arg) { _listener = (SocketAdapter)arg.AsyncState; CreateSocketForClients(_listener.EndAccept(arg)); _listener.BeginAccept(new AsyncCallback(AcceptClient), _listener); }