public void DeserializeWithStartTlsFeature() { var xml = @"<stream:features> <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'> <required/> </starttls> </stream:features>"; var features = XmppSerializer.Deserialize <StreamFeatures>("stream:features", xml); Assert.IsNotNull(features); Assert.IsNotNull(features.StartTls); Assert.IsNotNull(features.StartTls.Required); }
public void SerializeWithBindFeature() { var exp = @"<stream:features xmlns:stream=""http://etherx.jabber.org/streams""> <bind xmlns=""urn:ietf:params:xml:ns:xmpp-bind""/> </stream:features>"; var features = new StreamFeatures { Bind = new Bind() }; var buffer = XmppSerializer.Serialize(features); var xml = XmppEncoding.Utf8.GetString(buffer, 0, buffer.Length); Assert.IsTrue(exp.CultureAwareCompare(xml)); }
public void DeserializeRosterRequest() { var xml = @"<iq from='[email protected]/balcony' id='bv1bs71f' type='get' xmlns=""jabber:client""> <query xmlns='jabber:iq:roster'/> </iq>"; var infoQuery = XmppSerializer.Deserialize <InfoQuery>("iq", xml); Assert.IsNotNull(infoQuery); Assert.AreEqual("[email protected]/balcony", infoQuery.From); Assert.AreEqual(InfoQueryType.Get, infoQuery.Type); Assert.AreNotEqual(null, infoQuery.Roster); }
public void DeserializeWithCompressFeature() { var xml = @"<stream:features> <compression xmlns='http://jabber.org/features/compress'> <method>zlib</method> <method>lzw</method> </compression> </stream:features>"; var features = XmppSerializer.Deserialize <StreamFeatures>("stream:features", xml); Assert.IsNotNull(features); Assert.IsNotNull(features.Compression); Assert.AreEqual(2, features.Compression.Methods.Count); Assert.AreEqual("zlib", features.Compression.Methods[0]); Assert.AreEqual("lzw", features.Compression.Methods[1]); }
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(""); } }
public void SerializeWithStartTlsFeature() { var exp = @"<stream:features xmlns:stream=""http://etherx.jabber.org/streams""> <starttls xmlns=""urn:ietf:params:xml:ns:xmpp-tls""> <required /> </starttls> </stream:features>"; var features = new StreamFeatures { StartTls = new StartTls { Required = new Empty() , RequiredSpecified = true } }; var buffer = XmppSerializer.Serialize(features); var xml = XmppEncoding.Utf8.GetString(buffer, 0, buffer.Length); Assert.IsTrue(exp.CultureAwareCompare(xml)); }
public void SerializeRosterRequest() { var exp = @"<iq from=""[email protected]/balcony"" id=""bv1bs71f"" type=""get"" xmlns=""jabber:client""> <query xmlns=""jabber:iq:roster""/> </iq>"; var query = new InfoQuery { From = "[email protected]/balcony" , Id = "bv1bs71f" , Type = InfoQueryType.Get }; query.Roster = new Roster(); var buffer = XmppSerializer.Serialize(query); var xml = XmppEncoding.Utf8.GetString(buffer, 0, buffer.Length); Assert.IsTrue(exp.CultureAwareCompare(xml)); }
public void SerializeWithCompressFeature() { var exp = @"<stream:features xmlns:stream=""http://etherx.jabber.org/streams""> <compression xmlns=""http://jabber.org/features/compress""> <method>zlib</method> <method>lzw</method> </compression> </stream:features>"; var features = new StreamFeatures { Compression = new StreamCompressionFeature { Methods = new List <string> { "zlib", "lzw" } } }; var buffer = XmppSerializer.Serialize(features); var xml = XmppEncoding.Utf8.GetString(buffer, 0, buffer.Length); Assert.IsTrue(exp.CultureAwareCompare(xml)); }
/// <summary> /// Sends a new message. /// </summary> /// <param name = "message">The message to be sent</param> public override void Send(object message) { Send(XmppSerializer.Serialize(message)); }
private void Send(HttpBindBody message) { Send(XmppSerializer.Serialize(message)); }
/// <summary> /// Sends a new message. /// </summary> /// <param name="message">The message to be sent</param> public async Task SendAsync <T>(T message) where T : class { await this.transport.SendAsync(XmppSerializer.Serialize(message)).ConfigureAwait(false); }