XmppSharp 6.0.1
dotnet add package XmppSharp --version 6.0.1
NuGet\Install-Package XmppSharp -Version 6.0.1
<PackageReference Include="XmppSharp" Version="6.0.1" />
paket add XmppSharp --version 6.0.1
#r "nuget: XmppSharp, 6.0.1"
// Install XmppSharp as a Cake Addin #addin nuget:?package=XmppSharp&version=6.0.1 // Install XmppSharp as a Cake Tool #tool nuget:?package=XmppSharp&version=6.0.1
XMPP#
Lightweight XMPP library.
Supported features
- RFC-6120 - Core
- XEP-0004 - Data Forms
- XEP-0012 - Last Activity
- XEP-0030 - Service Discovery
- XEP-0045 - Multi User Chat
- XEP-0047 - In-Band Bytestreams
- XEP-0085 - Chat States Notifications
- XEP-0172 - User Nickname
- XEP-0199 - Ping
- XEP-0202 - Entity Time
- XEP-0203 - Delayed Delivery
Parsing
After XMPP# v6.0 we are using libexpat as default XML parser for xmpp protocol. But additional parsers can be implemented along with the lib.
You can still use older XMPP# version that includes builtin XMPP parser using XmlReader
or use <i>XMPP# Tokenizer</i> package.
The class XmppSharp.Dom.XmppDocument
was keep to provide basic XML parsing from file or string in a simple and fast way using .NET's XmlReader
.
Element Factory
The XmppElementFactory
class registers and maintains the mapping of all XML elements to their respective classes. Each element is qualified by a name (Tag name) and its namespace URI, when registered the parser will obtain this information and construct the class corresponding to the XML element. If the mapping does not exist, it will use a fallback by constructing an instance of XmppSharp.Dom.XmppElement
.
Consider the example table below demonstrating how this mapping works:
Qualified Tag Name | Namespace(s) | Mapped Class |
---|---|---|
iq | see note below | XmppSharp.Protocol.Core.Iq |
message | see note below | XmppSharp.Protocol.Core.Message |
presence | see note below | XmppSharp.Protocol.Core.Presence |
error | see note below | XmppSharp.Protocol.Base.StanzaError |
starttls | urn:ietf:params:xml:ns:xmpp-tls | XmppSharp.Protocol.Tls.StartTls |
success | urn:ietf:params:xml:ns:xmpp-sasl | XmppSharp.Protocol.Sasl.Success |
stream:features | http://etherx.jabber.org/streams | XmppSharp.Protocol.Base.StreamFeatures |
... | ... | ... |
[!NOTE] Some cases like
iq
,message
,presence
,error
(error element inside an stanza), have more than one namespace defined (because it depends on each specific namespace URI), but they are declared in the same way. The difference is that more than one namespace is assigned to this element, so theXmppElementFactory
can correctly map which one it will instantiate.
<hr/>
Defining your XML elements is simple, just create a class that inherits the base class XmppSharp.Dom.XmppElement
or similar, call the base constructor of the class to initialize the tag name correctly. And add the attribute [XmppTag(tagName, namespace)]
for each desired tag and namespace and register the type by calling XmppElementFactory.RegisterType
(or to register an entire assembly XmppElementFacotry.RegisterAssembly
), eg:
// define xmpp tags
[XmppTag("bind", Namespaces.Bind)]
public class Bind : XmppElement
{
public Bind() : base("bind", Namespaces.Bind) // call base constructor to setup this element instance.
{
// setup other properties...
}
}
<hr/>
Due internal reasons we merged expat parser into main package. We no longer provide default parser using XmlReader
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
NuGet packages (1)
Showing the top 1 NuGet packages that depend on XmppSharp:
Package | Downloads |
---|---|
XmppSharp.Expat
XMPP# expat parser implementation. |
GitHub repositories
This package is not used by any popular GitHub repositories.