Beispiel #1
0
        public override void Callback(IAsyncResult result)
        {
            if (_proxy.IsRunning)
            {
                _proxy.Socket = (ProxySocket)result.AsyncState;

                Socket _client_socket = _proxy.Socket.EndAccept(result);

                ClientEntity client = _client_creator.Handle(_client_socket.RemoteEndPoint as IPEndPoint);
                client = _client_linker.Handle(client, _client_socket);

                ClientEntity remote = _client_creator.Handle(_proxy.IpRedirectedStack.Dequeue());
                remote = _client_linker.Handle(remote, new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp));
                AbstractClientReceiveCallback remote_rcv_callback = new AbstractClientReceiveCallback(remote, client, _client_repository, _client_creator, _client_linker, _client_connector, _client_disconnector, _client_sender, ProxyTagEnum.Server);
                remote = _client_connector.Handle(remote, new ClientConnectCallback(remote, remote_rcv_callback));

                // wait remote client to connect
                while (!remote.IsRunning)
                {
                    ;
                }

                client = _client_receiver.Handle(client, new AbstractClientReceiveCallback(client, remote, _client_repository, _client_creator, _client_linker, _client_connector, _client_disconnector, _client_sender, ProxyTagEnum.Client));

                logger.Info("client connected");

                _proxy.Socket.BeginAccept(Callback, _proxy.Socket);
            }
        }
Beispiel #2
0
        public override void Callback(IAsyncResult result)
        {
            if (_server.IsRunning)
            {
                _server.Socket = (ProxySocket)result.AsyncState;

                Socket _client_socket = _server.Socket.EndAccept(result);

                ClientEntity client = _client_creator.Handle(_client_socket.RemoteEndPoint as IPEndPoint);
                client = _client_linker.Handle(client, _client_socket);
                client = _client_receiver.Handle(client, new ClientReceiveCallback(client));

                logger.Info("client connected");

                _server.Socket.BeginAccept(Callback, _server.Socket);
            }
        }