XmppSharp.Net 1.0.2

dotnet add package XmppSharp.Net --version 1.0.2
                    
NuGet\Install-Package XmppSharp.Net -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XmppSharp.Net" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XmppSharp.Net" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="XmppSharp.Net" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XmppSharp.Net --version 1.0.2
                    
#r "nuget: XmppSharp.Net, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=XmppSharp.Net&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=XmppSharp.Net&version=1.0.2
                    
Install as a Cake Tool

XMPP#Net

Client and component connection implementations using XMPP#.


This package contains the implementation of the client and components protocols. The goal is to split this package for specific uses.

For example, XMPP# itself is a library that implements classes, functions, etc., for use with the XMPP protocol itself, so the additional packages are extensions for this.

This package also implements the SASL factory and mechanisms (authentication) for client connections.

Register custom SASL handler

To register a SASL handler or overwrite an existing one, simply follow these steps:

  1. Create the class that extends the base class XmppSaslHandler.
public class SaslPlainHandler : XmppSaslHandler
{

}
  1. Override the Init method to send the initial authentication packet:
protected internal override void Init()
{
    var buf = new StringBuilder()
        .Append('\0')
        .Append(Connection.User)
        .Append('\0')
        .Append(Connection.Password)
        .ToString()
        .GetBytes();

    var el = new Auth
    {
        Mechanism = "PLAIN",
        Value = Convert.ToBase64String(buf)
    };

    Connection.Send(el);
}

In the case of the PLAIN mechanism, there are only 2 fields sent nullchar + user + nullchar + password.

  1. Override the Invoke method to handle xmpp elements in SASL handler:
protected internal override SaslHandlerResult Invoke(XmppElement e)
{
    // server responded with success.
    if (e is Success)
        return SaslHandlerResult.Success;

    // server responded with failure.
    if (e is Failure failure)
        return SaslHandlerResult.Failure(failure.Condition, failure.Text);

    // is not SASL element, skip.
    return SaslHandlerResult.Continue;
}

This is how the PLAIN mechanism is implemented on the client. And registering is simple. Just call the function: RegisterMechanism("PLAIN", c => new XmppSaslPlainHandler(c));


There are a few things to consider in this Invoke method.

  • It expects to return a SaslHandlerResult that tellswhether the authentication failed, succeeded, or ignored.

  • In the case of ignored, it means that the element was not processed by the SASL handler (it does not belong to the mechanism). If it is ignored, it will be sent to the OnElement event of the connection.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 143 5/28/2025
1.0.1 70 5/24/2025