Пример #1
0
        public override void InitializeXmppStream() {
            var message = new HttpBindBody();

            message.Rid = (rid++).ToString();
            message.To = ConnectionString.HostName;
            message.Lang = DefaultLanguage;

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

            var response = 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)
            {
                streamResponse = response;

                ProcessResponse(response);

#warning TODO: Check if the response has an stream-features element
                OnXmppStreamInitializedSubject.OnNext(String.Empty);
            }
            else
            {
#warning TODO: Review how to handle this case
                throw new Exception("");
            }
        }
Пример #2
0
        /// <summary>
        ///   Sends a new message.
        /// </summary>
        /// <param name = "message">The message to be sent</param>
        public override void Send(object message) {
            var body = new HttpBindBody
                           {
                               Rid = (rid++).ToString(),
                               Sid = streamResponse.Sid
                           };

            body.Items.Add(message);

            Send(XmppSerializer.Serialize(body));
        }
Пример #3
0
 private void ProcessResponse(HttpBindBody response) {
     foreach (var item in response.Items)
     {
         OnMessageReceivedSubject.OnNext(item);
     }
 }
Пример #4
0
 private void Send(HttpBindBody message) {
     Send(XmppSerializer.Serialize(message));
 }
Пример #5
0
        public override void Close() {
            base.Close();

            ServicePointManager.ServerCertificateValidationCallback -= ValidateRemoteCertificate;

            streamResponse = null;
            rid = 0;
        }