コード例 #1
0
ファイル: Program.cs プロジェクト: As-You-Like/DotNetStuff
        static void WrapperExample(NpcReflector npcReflector, INpcHtmlGenerator htmlGenerator, UInt16 port)
        {
            NpcServerSingleThreaded wrapper = new NpcServerSingleThreaded(NpcLoggerCallback.ConsoleLogger, npcReflector,
                                                                          htmlGenerator, port);

            wrapper.Run();
        }
コード例 #2
0
ファイル: NpcHandler.cs プロジェクト: As-You-Like/DotNetStuff
 public NpcBlockingThreadHander(String clientString, INpcServerCallback callback, Socket socket,
                                NpcExecutor npcExecutor, INpcHtmlGenerator npcHtmlGenerator)
     : base(clientString, callback, npcExecutor, npcHtmlGenerator)
 {
     this.socket           = socket;
     this.socketLineReader = new SocketLineReader(socket, Encoding.ASCII, Buf.DefaultInitialCapacity, Buf.DefaultExpandLength);
 }
コード例 #3
0
        public NpcServerSingleThreaded(INpcServerCallback callback, NpcExecutor npcExecutor, INpcHtmlGenerator htmlGenerator, UInt16 port)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }
            if (npcExecutor == null)
            {
                throw new ArgumentNullException("npcExecutor");
            }
            if (htmlGenerator == null)
            {
                throw new ArgumentNullException("htmlGenerator");
            }

            this.callback      = callback;
            this.npcExecutor   = npcExecutor;
            this.htmlGenerator = htmlGenerator;

            Socket listenSocket = new Socket(IPAddress.Any.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

            listenSocket.Bind(new IPEndPoint(IPAddress.Any, port));
            listenSocket.Listen(Backlog);
            callback.ServerListening(listenSocket);

            selectServer = new SelectServer(false, new Buf(SingleThreadedReceiveBufferLength));
            selectServer.control.AddListenSocket(listenSocket, AcceptCallback);
        }
コード例 #4
0
        public NpcSelectServerHandler(INpcServerCallback callback, NpcExecutor npcExecutor, INpcHtmlGenerator htmlGenerator)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }
            if (npcExecutor == null)
            {
                throw new ArgumentNullException("npcExecutor");
            }
            if (htmlGenerator == null)
            {
                throw new ArgumentNullException("htmlGenerator");
            }

            this.callback      = callback;
            this.npcExecutor   = npcExecutor;
            this.htmlGenerator = htmlGenerator;
        }
コード例 #5
0
ファイル: NpcHandler.cs プロジェクト: As-You-Like/DotNetStuff
        public NpcHandler(String clientString, INpcServerCallback callback, NpcExecutor npcExecutor, INpcHtmlGenerator npcHtmlGenerator)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }
            if (npcExecutor == null)
            {
                throw new ArgumentNullException("npcExecutor");
            }
            if (npcHtmlGenerator == null)
            {
                throw new ArgumentNullException("npcHtmlGenerator");
            }

            this.clientString = clientString;

            this.callback      = callback;
            this.npcExecutor   = npcExecutor;
            this.htmlGenerator = npcHtmlGenerator;
        }
コード例 #6
0
        public NpcServerMultiThreaded(INpcServerCallback callback, NpcExecutor npcExecutor, INpcHtmlGenerator htmlGenerator, UInt16 port)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }
            if (npcExecutor == null)
            {
                throw new ArgumentNullException("npcReflector");
            }
            if (htmlGenerator == null)
            {
                throw new ArgumentNullException("htmlGenerator");
            }

            this.callback      = callback;
            this.npcExecutor   = npcExecutor;
            this.htmlGenerator = htmlGenerator;
            this.port          = port;
            this.keepRunning   = false;
        }
コード例 #7
0
        public NpcServerSingleThreaded(INpcServerCallback callback, NpcExecutor npcExecutor, INpcHtmlGenerator htmlGenerator, Socket listenSocket)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }
            if (npcExecutor == null)
            {
                throw new ArgumentNullException("npcExecutor");
            }
            if (htmlGenerator == null)
            {
                throw new ArgumentNullException("htmlGenerator");
            }

            this.callback      = callback;
            this.npcExecutor   = npcExecutor;
            this.htmlGenerator = htmlGenerator;

            selectServer = new SelectServer(false, new Buf(SingleThreadedReceiveBufferLength));
            selectServer.control.AddListenSocket(listenSocket, AcceptCallback);
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: As-You-Like/DotNetStuff
        static void NoWrapperExample(NpcReflector npcReflector, INpcHtmlGenerator htmlGenerator, UInt16 port)
        {
            //
            // Accept Connections Loop
            //
            Socket listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            listenSocket.Bind(new IPEndPoint(IPAddress.Any, port));
            listenSocket.Listen(32);

            while (true)
            {
                Socket clientSocket = listenSocket.Accept();

                String clientString = clientSocket.RemoteEndPoint.ToString();
                Console.WriteLine("{0} [ListenThread] New Client '{1}'", DateTime.Now, clientString);

                NpcBlockingThreadHander npcHandler =
                    new NpcBlockingThreadHander(NpcLoggerCallback.ConsoleLogger, clientSocket, npcReflector, htmlGenerator);
                Thread handlerThread = new Thread(npcHandler.Run);
                handlerThread.Start();
            }
        }
コード例 #9
0
ファイル: NpcHandler.cs プロジェクト: As-You-Like/DotNetStuff
        public NpcSocketHandler(String clientString, INpcServerCallback callback, NpcExecutor npcExecutor, INpcHtmlGenerator npcHtmlGenerator)
            : base(clientString, callback, npcExecutor, npcHtmlGenerator)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            this.lineParser = new LineParser(Encoding.ASCII, Buf.DefaultInitialCapacity, Buf.DefaultExpandLength);
        }