Exemplo n.º 1
0
        public override void InitializeXmppStream()
        {
            HttpBindBody message = new HttpBindBody();

            message.Rid             = (this.rid++).ToString();
            message.To              = this.ConnectionString.HostName;
            message.Lang            = DefaultLanguage;
            
            if (this.streamResponse == null)
            {
                message.Content         = HttpTransport.ContentType;
                message.From            = this.UserId.BareIdentifier;
                message.Hold            = 1;
                message.HoldSpecified   = true;
                message.Route           = String.Format(RouteFormat, this.ConnectionString.HostName);
                message.Ver             = HttpTransport.BoshVersion;
                message.Wait            = 60;
                message.WaitSpecified   = true;
                message.Ack             = "1";
            }
            else
            {
                message.Sid     = this.streamResponse.Sid;
                message.Restart = true;
            }

            HttpBindBody response = this.SendSync(XmppSerializer.Serialize(message));

#warning TODO: If no <stream:features/> element is included in the connection manager's session creation response, then the client SHOULD send empty request elements until it receives a response containing a <stream:features/> element.

            if (response != null)
            {
                this.streamResponse = response;

                this.ProcessResponse(response);

#warning TODO: Check if the response has an stream-features element
                this.OnXmppStreamInitializedSubject.OnNext(String.Empty);
            }
            else
            {
#warning TODO: Review how to handle this case
                throw new Exception("");
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Sends a new message.
 /// </summary>
 /// <param elementname="message">The message to be sent</param>
 private void Send(HttpBindBody message)
 {
     this.Send(XmppSerializer.Serialize(message));
 }
Exemplo n.º 3
0
        public override void Close()
        {
            base.Close();

            ServicePointManager.ServerCertificateValidationCallback -= new RemoteCertificateValidationCallback(ValidateRemoteCertificate);

            this.streamResponse     = null;
            this.rid                = 0;
        }
Exemplo n.º 4
0
 private void ProcessResponse(HttpBindBody response)
 {
     foreach (object item in response.Items)
     {
         this.OnMessageReceivedSubject.OnNext(item);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Sends a new message.
        /// </summary>
        /// <param elementname="message">The message to be sent</param>
        public override void Send(object message)
        {
            HttpBindBody body = new HttpBindBody();

            body.Rid = (this.rid++).ToString();
            body.Sid = this.streamResponse.Sid;

            body.Items.Add(message);

            this.Send(XmppSerializer.Serialize(body));
        }