Exemplo n.º 1
0
        private void CloseDesktopView(dynamic request)
        {
            string id = request.Id;

            if (this._sessionDictionary.ContainsKey(id))
            {
                SessionProviderContext session = this._sessionDictionary[id];
                if ((bool)session.AppTokens[2])
                {
                    session.AppTokens[2] = false;

                    byte[] data = Core.MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_DESKTOPVIEW_CLOSE);
                    session.SendAsync(data);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取桌面视图
        /// </summary>
        /// <param name="id"></param>
        private void PullDesktopView(string id)
        {
            if (this._sessionDictionary.ContainsKey(id))
            {
                SessionProviderContext session = this._sessionDictionary[id];

                if (!(bool)session.AppTokens[2])
                {
                    return;
                }

                byte[] data = Core.MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_DESKTOPVIEW_GETFRAME, _desktopView_width + "|" + _desktopView_height + "|" + _desktopView_spantime);
                session.SendAsync(data);

                this.PutLogQueue("DEBUG pull Image height:" + _desktopView_height + " width:" + _desktopView_width);
            }
        }
Exemplo n.º 3
0
        private void OpenDesktopView(dynamic request)
        {
            string id = request.Id;

            if (this._sessionDictionary.ContainsKey(id))
            {
                SessionProviderContext session = this._sessionDictionary[id];
                if (!(bool)session.AppTokens[2])
                {
                    byte[] data = Core.MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_CREATE_DESKTOPVIEW);
                    session.SendAsync(data);

                    session.AppTokens[2] = true;
                    this.PullDesktopView(id);
                }
            }
        }
Exemplo n.º 4
0
        private void OnMessage(SessionProviderContext session)
        {
            object[]           ars             = session.AppTokens;
            ConnectionWorkType sessionWorkType = (ConnectionWorkType)ars[0];

            if (sessionWorkType == ConnectionWorkType.WORKCON)
            {
                //消息扔给消息提供器,由提供器提供消息给所在窗口进行消息处理
                //((MessageAdapter)ars[1]).OnSessionNotify(session, SessionNotifyType.Message);
            }
            else if (sessionWorkType == ConnectionWorkType.MAINCON)
            {
                MessageHead cmd = session.CompletedBuffer.GetMessageHead <MessageHead>();
                switch (cmd)
                {
                case MessageHead.C_MAIN_LOGIN:    //上线包
                    this.ProcessLogin(session);
                    break;

                case MessageHead.C_MAIN_DESKTOPVIEW_FRAME:    //屏幕视图数据
                    this.ProcessDesktopViewData(session, session.CompletedBuffer.GetMessagePayload());
                    break;
                }
            }
            else if (sessionWorkType == ConnectionWorkType.NONE) //初始消息只能进入该方法块处理,连接密码验证正确才能正式处理消息
            {
                switch (session.CompletedBuffer.GetMessageHead <MessageHead>())
                {
                case MessageHead.C_GLOBAL_CONNECT:    //连接确认包
                                                      //CheckSessionValidity(session);

                    session.AppTokens[0] = ConnectionWorkType.MAINCON;

                    byte[] data = Core.MessageHelper.CopyMessageHeadTo(MessageHead.S_GLOBAL_OK);
                    session.SendAsync(data);

                    break;

                default:
                    session.SessionClose();    //伪造包断掉
                    break;
                }
            }
        }
 protected virtual void SendTo(SessionProviderContext session, byte[] data)
 {
     session.SendAsync(data);
 }