예제 #1
0
        public TwoWaySocketTunnel(
            Socket socketA, Socket socketB, Int32 readBufferSize,
            ConnectionMessageLogger messageLogger, IConnectionDataLogger dataLogger)
        {
            if (messageLogger == null)
            {
                throw new ArgumentNullException("messageLogger");
            }
            if (dataLogger == null)
            {
                throw new ArgumentNullException("dataLogger");
            }

            if (socketA == null)
            {
                throw new ArgumentNullException("socketA");
            }
            if (socketB == null)
            {
                throw new ArgumentNullException("socketB");
            }

            this.socketA = socketA;
            this.socketB = socketB;

            this.tunnelAToB = new OneWaySocketTunnel(this, socketA, socketB, readBufferSize,
                                                     messageLogger.AToBMessageLogger, dataLogger.AToBDataLogger);
            this.tunnelBToA = new OneWaySocketTunnel(this, socketB, socketA, readBufferSize,
                                                     messageLogger.BToAMessageLogger, dataLogger.BToADataLogger);
            this.tunnelClosed = false;

            this.messageLogger = messageLogger;
            this.dataLogger    = dataLogger;
        }
예제 #2
0
        public HttpRequestHandler(IResourceHandler resourceHandler, NetworkStream stream,
                                  MessageLogger messageLogger, IConnectionDataLogger connectionDataLogger)
        {
            if (resourceHandler == null)
            {
                throw new ArgumentNullException("resourceHandler");
            }
            if (stream == null)
            {
                throw new ArgumentNullException("null");
            }

            this.resourceHandler = resourceHandler;
            this.stream          = stream;

            this.messageLogger        = (messageLogger == null) ? MessageLogger.NullMessageLogger : messageLogger;
            this.connectionDataLogger = (connectionDataLogger == null) ? ConnectionDataLogger.Null : connectionDataLogger;
        }
예제 #3
0
        public ConsoleClient(Int32 sendFileBufferSize, Int32 recvBufferSize, InternetHost serverHost,
                             MessageLogger messageLogger, IConnectionDataLogger connectionLogger)
        {
            this.sendFileBufferSize = sendFileBufferSize;
            this.recvBufferSize     = recvBufferSize;

            this.serverHost = serverHost;

            this.messageLogger    = messageLogger;
            this.connectionLogger = connectionLogger;

            commandDictionary = new Dictionary <String, CommandFunction>();
            commandDictionary.Add("open", OpenCommand);
            commandDictionary.Add("close", CloseCommand);
            commandDictionary.Add("send", SendCommand);
            commandDictionary.Add("sendfile", SendFileCommand);
            commandDictionary.Add("proxy", ProxyCommand);
            commandDictionary.Add("help", HelpCommand);
            commandDictionary.Add("exit", ExitCommand);
            commandDictionary.Add("echo", EchoCommand);
        }