XmppSharp 5.0.2
dotnet add package XmppSharp --version 5.0.2
NuGet\Install-Package XmppSharp -Version 5.0.2
<PackageReference Include="XmppSharp" Version="5.0.2" />
paket add XmppSharp --version 5.0.2
#r "nuget: XmppSharp, 5.0.2"
// Install XmppSharp as a Cake Addin #addin nuget:?package=XmppSharp&version=5.0.2 // Install XmppSharp as a Cake Tool #tool nuget:?package=XmppSharp&version=5.0.2
XMPP#
Lightweight XMPP library.
<hr/>
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
<hr/>
Parsing
The lib uses XmlReader
as a base to read and tokenize the XML stream for the XMPP protocol. It can control and maintain the XML state in a stable and secure way.
Additional parsers can be implemented along with the lib. For example, the default implementation of XmppSharp.Expat
contains the basic code for XML parsing using the expat parser (basically one of the best XML parsers out there).
Consider that some parsers (like our official implementation of XmppSharp.Expat
) use external libraries, requiring P/Invoking, which requires the user to have already installed the library on their computer. The most practical way to obtain these compiled libraries is using vcpkg (in the case of expat, they have releases ready for download in the official repository).
In the current version we introduced a new class XmppSharp.Dom.Document
that aims to parse an XML file or even an XML string in a simple and fast way without also depending on System.Xml
using fully the Xmpp Sharp APIs! It supports both reading and writing an XML document to a file or string.
Element Factory
The ElementFactory
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.Element
.
Consider the example table below demonstrating how this mapping works:
Qualified Tag Name | Namespace(s) | Mapped Class |
---|---|---|
iq | see below | XmppSharp.Protocol.Iq |
message | see below | XmppSharp.Protocol.Iq |
presence | see below | XmppSharp.Protocol.Iq |
error | see 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 piece of the protocol), but they are declared in the same way. The difference is that more than one namespace is assigned to this element, so theElementFactory
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.Element
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 ElementFactory.RegisterType
(or to register an entire assembly ElementFacotry.RegisterAssembly
), eg:
// define xmpp tags
[XmppTag("bind", Namespaces.Bind)]
public class Bind : Element
{
public Bind() : base("bind", Namespaces.Bind) // call base constructor to set-up this element instance.
{
...
}
}
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. |
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
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.