예제 #1
0
        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);
        }
예제 #2
0
        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();
            }
        }
예제 #3
0
 private void AcceptClient(IAsyncResult arg)
 {
     _listener = (SocketAdapter)arg.AsyncState;
     CreateSocketForClients(_listener.EndAccept(arg));
     _listener.BeginAccept(new AsyncCallback(AcceptClient), _listener);
 }