Exemplo n.º 1
0
        public static AbstractServer GetServer(ServerType serverType, string port)
        {
            AbstractServer         server         = null;
            AbstractHandlerFactory handlerFactory = null;
            AbstractCommandHandler handler        = null;

            switch (serverType)
            {
            case ServerType.TCPServer:
                server         = new TCPServer(port);
                handlerFactory = new TCPHandlerFactory();
                break;

            case ServerType.FileServer:
                port           = GetFilserverPort(port);
                server         = new FileServer(300, port);
                handlerFactory = new FileHandlerFactory();
                break;

            case ServerType.SyncFileServer:
                port           = GetFilserverPort(port);
                server         = new SyncFileServer(300, port);
                handlerFactory = new FileHandlerFactory();
                break;
            }

            server.commandHandler = handlerFactory.GetKeyBoardRequestHandler();
            handler = server.commandHandler.SetNextHandler(handlerFactory.GetMouseRequestHandler());
            handler = handler.SetNextHandler(handlerFactory.GetKeyLoggerRequestHandler());
            handler = handler.SetNextHandler(handlerFactory.GetScreenRequestHandler());
            handler.SetNextHandler(handlerFactory.GetDefaultRequestHandler());
            return(server);
        }
Exemplo n.º 2
0
 public void Start(ServerType serverType, string port)
 {
     server = SeverFactory.GetServer(serverType, port);
     server.Start();
 }