private void Client_OpenWriteCompleted(object sender, CapsBase.OpenWriteCompletedEventArgs e)
        {
            bool raiseEvent = false;

            if (!_Dead)
            {
                if (!_Running)
                {
                    raiseEvent = true;
                }

                // We are connected to the event queue
                _Running = true;
            }

            // Create an EventQueueGet request
            LLSDMap request = new LLSDMap();

            request["ack"]  = new LLSD();
            request["done"] = LLSD.FromBoolean(false);

            byte[] postData = LLSDParser.SerializeXmlBytes(request);

            _Client.UploadDataAsync(_Client.Location, postData);

            if (raiseEvent)
            {
                Logger.DebugLog("Capabilities event queue connected");

                // The event queue is starting up for the first time
                if (OnConnected != null)
                {
                    try { OnConnected(); }
                    catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, ex); }
                }
            }
        }
Example #2
0
        public void StartRequest(byte[] postData, string contentType)
        {
            _PostData    = postData;
            _ContentType = contentType;

            if (_Client.IsBusy)
            {
                Logger.Log("New CAPS request to " + _Client.Location +
                           " initiated, closing previous request", Helpers.LogLevel.Warning);
                _Client.CancelAsync();
            }
            else
            {
                Logger.DebugLog("New CAPS request to " + _Client.Location + " initiated");
            }

            _Client.Headers.Clear();

            // Proxy
            if (Proxy != null)
            {
                _Client.Proxy = Proxy;
            }

            // Content-Type
            if (!String.IsNullOrEmpty(contentType))
            {
                _Client.Headers.Add(HttpRequestHeader.ContentType, contentType);
            }
            else
            {
                _Client.Headers.Add(HttpRequestHeader.ContentType, "application/xml");
            }

            if (postData == null)
            {
                _Client.DownloadStringAsync(_Client.Location);
            }
            else
            {
                _Client.UploadDataAsync(_Client.Location, postData);
            }
        }