예제 #1
0
        private void HandleMessagePump()
        {
            while (true)
            {
                GuacMessage msg = this.m_readQueue.Take();
                switch (msg.Command)
                {
                case "name":
                    this.Name = msg.Args[0];
                    break;

                case "size":
                    this.ResizeLayer(int.Parse(msg.Args[0]), int.Parse(msg.Args[1]), int.Parse(msg.Args[2]));
                    break;

                case "png":
                    this.DrawPng((Operation)int.Parse(msg.Args[0]), int.Parse(msg.Args[1]), int.Parse(msg.Args[2]), int.Parse(msg.Args[3]), Convert.FromBase64String(msg.Args[4]));
                    break;

                case "cursor":
                    this.SetCursorData(int.Parse(msg.Args[0]), int.Parse(msg.Args[1]), int.Parse(msg.Args[2]), int.Parse(msg.Args[3]), int.Parse(msg.Args[4]), int.Parse(msg.Args[5]), int.Parse(msg.Args[6]));
                    break;

                case "sync":
                    TimeSpan ts = TimeSpan.FromMilliseconds(ulong.Parse(msg.Args[0]));
                    this.m_writeStream.WriteInstruction("sync", ((ulong)(new DateTime(1970, 1, 1) - DateTime.Now).TotalMilliseconds)).Wait();
                    break;

                case "copy":
                    this.Copy(int.Parse(msg.Args[0]), int.Parse(msg.Args[1]), int.Parse(msg.Args[2]), int.Parse(msg.Args[3]), int.Parse(msg.Args[4]), (Operation)int.Parse(msg.Args[5]), int.Parse(msg.Args[6]), int.Parse(msg.Args[7]), int.Parse(msg.Args[8]));
                    break;

                default:
                    System.Diagnostics.Debugger.Break();
                    break;
                }
            }
        }
예제 #2
0
        public async Task Start(string hostname, int port, int width, int height, int color_depth)
        {
            await this.m_tcp.ConnectAsyncTask(this.m_server);

            this.m_readStream  = new NetworkStream(this.m_tcp);
            this.m_writeStream = new BufferedStream(this.m_readStream);
            this.m_readStreamPump.Start();

            //handshake
            await this.m_writeStream.Select("rdp");

            GuacMessage args = await this.m_readQueue.TakeAsync();

            await this.m_writeStream.Size(1024, 768, 96);

            await this.m_writeStream.WriteInstruction("audio");

            await this.m_writeStream.WriteInstruction("video");

            System.Diagnostics.Debug.WriteLine("Args to send : " + args.Args.Length);
            await this.m_writeStream.Connect_Rdp(hostname : hostname, port : port, width : width, height : height, color_depth : color_depth, disable_auth : true);

            this.m_handleMessagePump.Start();
        }