示例#1
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.Unicode;

            Squad.Init();

            string InHandle  = args[0];
            string OutHandle = args[1];

            new Thread(delegate()
            {
                DedicatedServer.Receiver = new AnonymousPipeClientStream(PipeDirection.In, InHandle);
                DedicatedServer.Sender   = new AnonymousPipeClientStream(PipeDirection.Out, OutHandle);
                DedicatedServer.Running  = true;

                DedicatedServer.SenderWrite           = new StreamWriter(DedicatedServer.Sender);
                DedicatedServer.SenderWrite.AutoFlush = true;

                using (StreamReader Reader = new StreamReader(DedicatedServer.Receiver))
                {
                    string Received;
                    do
                    {
                        Received = Reader.ReadLine();
                    }while (!Received.StartsWith("SYNC") && DedicatedServer.Running);

                    while (DedicatedServer.Running && DedicatedServer.Receiver.IsConnected)
                    {
                        Received = Reader.ReadLine();
                        if (Received != null)
                        {
                            Start(Received);
                        }
                    }
                    DedicatedServer.Running = false;
                }
            }).Start();
        }