Ejemplo n.º 1
0
        private void TestFortewaveWin_Load(object sender, EventArgs e)
        {
            _ftwv = new Fortewave("UNREAL-TEST-CS-R", "UNREAL-TEST-CS-S");             // 引数の並び -> Recver, Sender

            _th = new Thread((ThreadStart) delegate
            {
                while (_death == false)
                {
                    object recvObj = _ftwv.recv(2000);

                    if (recvObj != null)
                    {
                        string message = StringTools.ENCODING_SJIS.GetString((byte[])recvObj);

                        this.BeginInvoke((MethodInvoker) delegate
                        {
                            txtRecv.Text          += "\r\n" + message;
                            txtRecv.SelectionStart = txtRecv.TextLength;
                            txtRecv.ScrollToCaret();
                        });
                    }
                }
            });
            _th.Start();
        }
Ejemplo n.º 2
0
        public void eachTimerTick()
        {
            lastScreenImage = null;
            lastMouseCursor = null;

            for (; ;)
            {
                object recvObj = _frtwv.recv(0);

                if (recvObj == null)
                {
                    break;
                }

                ObjectList ol       = (ObjectList)recvObj;
                byte[]     recvData = (byte[])ol[0];
                int        c        = 0;

                try
                {
                    switch ((char)recvData[c++])
                    {
                    case 'I':                             // screen Image
                    {
                        Image img = Bitmap.FromStream(new MemoryStream(recvData, c, recvData.Length - c));

                        if (img.Width < Ground.i.screen_w_min)
                        {
                            throw new Exception("スクリーンの幅が小さすぎます。");
                        }

                        if (img.Height < Ground.i.screen_h_min)
                        {
                            throw new Exception("スクリーンの高さが小さすぎます。");
                        }

                        if (Ground.i.screen_w_max < img.Width)
                        {
                            throw new Exception("スクリーンの幅が大き過ぎます。");
                        }

                        if (Ground.i.screen_h_max < img.Height)
                        {
                            throw new Exception("スクリーンの高さが大き過ぎます。");
                        }

                        lastScreenImage = img;
                    }
                    break;

                    case 'B':                             // clip-Board text
                    {
                        byte[] bText = BinaryTools.getSubBytes(recvData, c, recvData.Length - c);
                        string text  = JString.toJString(bText, true, true, true, true);

                        Clipboard.SetText(text);
                    }
                    break;

                    case 'C':                             // mouse Cursor kind
                    {
                        Cursor mouseCursor = Consts.mouseCursors[recvData[c++]];

                        lastMouseCursor = mouseCursor;
                    }
                    break;

                    default:
                        throw new Exception("不明なコマンド");
                    }
                }
                catch (Exception e)
                {
                    Utils.WriteLog("受信データが壊れています:" + e);
                }
                GC.Collect();
            }
        }
Ejemplo n.º 3
0
        public void eachTimerTick()
        {
            try
            {
                for (; ;)
                {
                    ObjectList ol = (ObjectList)_frtwv.recv(0);

                    if (ol == null)
                    {
                        break;
                    }

                    byte[]        recvData = (byte[])ol[0];
                    string        recvLine = StringTools.ENCODING_SJIS.GetString(recvData);
                    List <string> prms     = StringTools.tokenize(recvLine, " ");
                    int           c        = 0;
                    string        command  = prms[c++];

                    // 受信コマンド処理 >

                    if (command == "SENDER-IDLING")
                    {
                        _frtwv.send(Utils.toOL(
                                        "SEND-TO-CLIENT",
                                        Utils.getScreenImage(monitorIndex, quality),
                                        ""
                                        ));
                    }
                    else if (command == "MONITOR-INDEX")
                    {
                        monitorIndex  = int.Parse(prms[c++]);
                        monitorIndex  = IntTools.toRange(monitorIndex, 0, IntTools.IMAX);
                        monitorIndex %= Ground.i.monitorCenter.getCount();

                        MonitorCenter.Monitor monitor = Ground.i.monitorCenter.get(monitorIndex);

                        _frtwv.send(Utils.toOL(
                                        "MOUSE_LTRB " +
                                        monitor.l + " " +
                                        monitor.t + " " +
                                        monitor.r + " " +
                                        monitor.b
                                        ));
                    }
                    else if (command == "QUALITY")
                    {
                        quality = int.Parse(prms[c++]);
                        quality = IntTools.toRange(quality, 0, 101);
                    }
                    else if (command == "DISCONNECTED")
                    {
                        if (Ground.i.disconnectAndShiftKeysUp)
                        {
                            _frtwv.send(Utils.toOL("SHIFT-KEYS-UP"));
                        }
                    }
                    else if (command == "SET-CLIP-BOARD-TEXT")
                    {
                        byte[] bText = StringTools.decodeBase64(prms[c++]);
                        string text  = JString.toJString(bText, true, true, true, true);

                        Clipboard.SetText(text);
                    }
                    else if (command == "GET-CLIP-BOARD-TEXT")
                    {
                        string text = Clipboard.GetText();

                        if (string.IsNullOrEmpty(text))
                        {
                            text = "(クリップボードにテキストはありません[S])";
                        }

                        if (Consts.CLIPBOARD_TEXT_LEN_MAX < text.Length)
                        {
                            text = "(クリップボードのテキストは長すぎます[S])";
                        }

                        _frtwv.send(Utils.toOL(
                                        "SEND-TO-CLIENT",
                                        "",
                                        text
                                        ));
                    }
                    else
                    {
                        Utils.WriteLog("不明なコマンド:" + command);
                    }

                    // < 受信コマンド処理
                }
            }
            catch (Exception e)
            {
                Utils.WriteLog("Service each-timer error: " + e);
                GC.Collect();
            }
        }