Example #1
0
        void OnGetHandle(Srpc.Message response)
        {
            _sContext    = response.GetString("hResult");
            _bHasContext = true;

            SendContextOpen();

            // Before Show, so that the browser window is known and can manage the Show
            if (_nNativeHWND != 0)
            {
                SendContextNativeWindow(_sNativeVersion, _nNativeHWND);
            }

            if (_bShow)
            {
                SendContextShow();
            }
            else
            {
                SendContextHide();
            }

            //SendContextPosition(200, 800);
            //SendContextSize(600, 400);
        }
Example #2
0
        void OnReceived(IAsyncResult iar)
        {
            //Socket remoteSocket = (Socket)iar.AsyncState; // disposed

            lock (this) {
                if (_socket == null)
                {
                    OnDisconnected();
                }
                else
                {
                    _bReceiving = false;
                    int nBytesRead = 0;
                    try {
                        nBytesRead = _socket.EndReceive(iar);
                    } catch { }

                    if (nBytesRead == 0)
                    {
                        OnDisconnected();
                    }
                    else
                    {
                        string sData = Encoding.UTF8.GetString(_bytes, 0, nBytesRead);
                        Log("IN " + sData);
                        _sBuffer += sData;

                        Srpc.Message srpc = null;
                        do
                        {
                            srpc = ProcessData(ref _sBuffer);
                            if (srpc != null)
                            {
                                string sSrpcId = srpc.GetString("SrpcId");
                                if (!String.IsNullOrEmpty(sSrpcId))
                                {
                                    HandleResponse(srpc, sSrpcId);
                                }
                                else
                                {
                                    HandleRequest(srpc);
                                }
                            }
                        } while (srpc != null);

                        Receive();
                    }
                }
            }
        }