Ejemplo n.º 1
0
        public async void Start()
        {
            server = new NamedPipeWrapper.NamedPipeServer("discord-ipc-0");
            server.StartListen();
            server.ClientConnected    += Server_ClientConnected;
            server.ClientDisconnected += Server_ClientDisconnected;
            Console.WriteLine("DiscordPipeServer is listening");
            while (!abort)
            {
                var result = await server.AwaitSingleMessageAsync <PipeFrame>();

                var frame = (PipeFrame)result.MessageObject;
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("NEW FRAME:");
                Console.ForegroundColor = ConsoleColor.DarkGray;
                Console.WriteLine("Opcode=" + frame.Opcode);
                Console.WriteLine("Message=" + frame.Message);
                Console.ForegroundColor = ConsoleColor.White;
                HandleMessage(frame);

                /*PipeFrame frame = new PipeFrame();
                 * using(var stream = new MemoryStream(bytes))
                 * {
                 *  frame.ReadStream(stream);
                 *  Console.ForegroundColor = ConsoleColor.White;
                 *  Console.WriteLine("NEW FRAME:");
                 *  Console.ForegroundColor = ConsoleColor.Gray;
                 *  Console.WriteLine("Opcode=" + frame.Opcode);
                 *  Console.WriteLine("Message=" + frame.Message);
                 *  Console.ForegroundColor = ConsoleColor.White;
                 * }*/
            }
            Console.WriteLine("Started DiscordPipeServer");
        }
Ejemplo n.º 2
0
 private void OnClientDisconnected(NamedPipeServer server)
 {
     ClientDisconnected?.Invoke(this, new ClientConnectedArgs(server));
 }
Ejemplo n.º 3
0
 public ClientConnectedArgs(NamedPipeServer server)
 {
     Server = server;
 }