Git Product home page Git Product logo

sharpxmpp's Introduction

SharpXMPP

XMPP library for .NET/Xamarin/.NET Core

The library consists of two NuGet packages:

  • SharpXMPP: NuGet: SharpXMPP
  • SharpXMPP.WebSocket: NuGet: SharpXMPP.WebSocket

License: LGPLv3

Additional docs

sharpxmpp's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sharpxmpp's Issues

MUC Support

I am using your library and pretty happy, I just looking for the MUC chat can you please guide me is this library supports MUC Conversation.

Thanks

Equality for JID

I think it makes sense to define custom equality for the JID type, because it is such a simple value object.

DnsResolver uses hardcoded DNS server

Hi,

I am using Xamarin Forms and recently updated with latest Nuget package, it works fine in simulator but on connection it is crashing when I run on physical device.

Thanks

XmppComponent

Hello,

For XmppComponent, the spec requires that the To field be the component name.
( to="componentname.domain" )

Could XmppTcpConnection be modified to use this format when connecting with the 'jabber:component:accept' namespace?

IOS Physical Device Issue

Hi,

I am able to use this library in simulator but on physical device I am getting the following error.

List of configured name servers must not be empty.
Parameter name: servers

LookupClient.QueryInternalAsync (DnsClient.DnsQuestion question, DnsClient.DnsQuerySettings queryOptions, System.Collections.Generic.IReadOnlyCollection`1[T] servers, System.Threading.CancellationToken cancellationToken)
SharpXMPP
XmppTcpConnection.ResolveHostAddresses (System.Threading.CancellationToken cancellationToken)
SharpXMPP
XmppTcpConnection.ConnectAsync (System.Threading.CancellationToken token

DEBUG Error

at DnsClient.LookupClient.QueryInternalAsync (DnsClient.DnsQuestion question, DnsClient.DnsQuerySettings queryOptions, System.Collections.Generic.IReadOnlyCollection`1[T] servers, System.Threading.CancellationToken cancellationToken) [0x00061] in <519bb9af32234e5dba6bd0b076a88151>:0
at SharpXMPP.XmppTcpConnection.ResolveHostAddresses (System.Threading.CancellationToken cancellationToken) [0x00089] in /Users/impro/Downloads/SharpXMPP-master/SharpXMPP.Shared/XmppTcpConnection.cs:307
at SharpXMPP.XmppTcpConnection.ConnectAsync (System.Threading.CancellationToken token) [0x00048] in /Users/impro/Downloads/SharpXMPP-master/SharpXMPP.Shared/XmppTcpConnection.cs:171
at SharpXMPP.Client.LoginPage.Login_Click (System.Object sender, System.EventArgs args) [0x0011d] in /Users/impro/Downloads/SharpXMPP-master/SharpXMPP.Xamarin/SharpXMPP.Client/LoginPage.xaml.cs:34
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSAction.cs:178
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) [0x0003b] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:85
at SharpXMPP.Client.iOS.Application.Main (System.String[] args) [0x00001] in /Users/impro/Downloads/SharpXMPP-master/SharpXMPP.Xamarin/SharpXMPP.Client.iOS/Main.cs:12

Presence catch

Hi,

Using presence event handler I am able to get the realtime present of my friends those who attached to my roaster.
Now I can see the presence xml but little bit confuse how can I can easily fetch the Presence modes.
There is different xml for different modes likewise "Available , offline , away".
Following are all three types of presence xml. Just needed help is there any best approach is there to retrieve the presence from xml quickly or I need to parse/process the xml.

Available
<presence xml:lang="en" to="[email protected]/13095181656749857862393730" from="3458313788@ abc.com/gajim.233RA8V4" id="9b8943d3-aa0d-474c-9554-396ca73e3874" xmlns="jabber:client"> <c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://gajim.org" ver="em/Gre+83xcNyMTMuavGSvT8wxA=" /> <x xmlns="vcard-temp:x:update" /> <delay from="[email protected]/gajim.233RA8V4" stamp="2020-09-23T16:59:29.126617Z" xmlns="urn:xmpp:delay" /> </presence>
offline
<presence xml:lang="en" to="[email protected]/13095181656749857862393730" from="[email protected]/gajim.233RA8V4" type="unavailable" id="e163f46e-e67c-4b60-ada6-e279ecadab8c" xmlns="jabber:client" />

Away
<presence xml:lang="en" to="[email protected]/13095181656749857862393730" from="[email protected]/gajim.233RA8V4" id="cc97741a-cb81-455b-9217-4cab9cb5842c" xmlns="jabber:client"> <c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://gajim.org" ver="em/Gre+83xcNyMTMuavGSvT8wxA=" /> <x xmlns="vcard-temp:x:update" /> <show>away</show> </presence>

Running latest sample is causing issues but only in Android

at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Boolean runSynchronously, Mono.Net.Security.MonoSslAuthenticationOptions options, System.Threading.CancellationToken cancellationToken) [0x0025c] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:310
at SharpXMPP.XmppTcpConnection.InitTlsIfSupported (SharpXMPP.XMPP.Stream.Elements.Features features, System.Threading.CancellationToken cancellationToken) [0x000b7] in /Users/impro/Downloads/SharpXMPP-master/SharpXMPP.Shared/XmppTcpConnection.cs:343
at SharpXMPP.XmppTcpConnection.ConnectAsync (System.Threading.CancellationToken token) [0x00160] in /Users/impro/Downloads/SharpXMPP-master/SharpXMPP.Shared/XmppTcpConnection.cs:176
at SharpXMPP.Client.LoginPage.Login_Click (System.Object sender, System.EventArgs args) [0x000ef] in /Users/impro/Downloads/SharpXMPP-master/SharpXMPP.Xamarin/SharpXMPP.Client/LoginPage.xaml.cs:33
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at Android.App.SyncContext+<>c__DisplayClass2_0.b__0 () [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:36
at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-29/mcw/Java.Lang.IRunnable.cs:84
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.24(intptr,intptr)

Add Readme

Readme should describe the library purpose, capabilities, and proposed usage.

Enable CI

The library should periodically build on Travis and Appveyor.

Error on MUC Join in Xamarin Forms

    var username = "3111";
        var password = "3111";

var Client = new XmppClient
(new JID($"{username}@blah.com"), password, true);
Client.ConnectAsync();

        BookmarkedConference bookmarkedConference = new BookmarkedConference();
        bookmarkedConference.SetAttributeValue("JID", "[email protected]");
        bookmarkedConference.SetAttributeValue("Nick", "John");

        Client.BookmarkManager.Join
            (bookmarkedConference);

image

SCRAM-SHA-1-PLUS + SCRAM-SHA-224(-PLUS) + SCRAM-SHA-256(-PLUS) + SCRAM-SHA-384(-PLUS) + SCRAM-SHA-512(-PLUS) + SCRAM-SHA3-512(-PLUS) supports

After:

  • SCRAM-SHA-1

Can you add supports of :

  • SCRAM-SHA-1-PLUS
  • SCRAM-SHA-224
  • SCRAM-SHA-224-PLUS
  • SCRAM-SHA-256
  • SCRAM-SHA-256-PLUS
  • SCRAM-SHA-384
  • SCRAM-SHA-384-PLUS
  • SCRAM-SHA-512
  • SCRAM-SHA-512-PLUS
  • SCRAM-SHA3-512
  • SCRAM-SHA3-512-PLUS

"When using the SASL SCRAM mechanism, the SCRAM-SHA-256-PLUS variant SHOULD be preferred over the SCRAM-SHA-256 variant, and SHA-256 variants [RFC7677] SHOULD be preferred over SHA-1 variants [RFC5802]".

https://xmpp.org/extensions/inbox/hash-recommendations.html

-PLUS variants:

LDAP:

  • RFC5803: Lightweight Directory Access Protocol (LDAP) Schema for Storing Salted: Challenge Response Authentication Mechanism (SCRAM) Secrets: https://tools.ietf.org/html/rfc5803

HTTP:

2FA:

IANA:

Linked to:

XEP-0384: OMEMO Encryption

Message Delivery (XEP-0184, XEP-0333)

Hi,

I am using this library and pretty happy. Now I am looking to get information about the message delivery.
Is there any way I can track the message delivery information.

Thanks

System.NullReferenceException

{
  "length": 0,
  "offset": 0,
  "id": "fd75c885-3fc1-4b52-8943-a7e28d1f2b30",
  "exception": {
    "type": "System.NullReferenceException",
    "message": "Object reference not set to an instance of an object",
    "stackTrace": "  at SharpXMPP.XmppTcpConnection.InitTlsIfSupported (SharpXMPP.XMPP.Stream.Elements.Features features) <0x1065ec560 + 0x00038> in <af879d82b0fe4cf8b1d541279e6c3414#0835d9c74997d27a0e543614112fcf97>:0 \n  at SharpXMPP.XmppTcpConnection.ConnectAsync (System.Threading.CancellationToken token) <0x1065ea9a0 + 0x0046f> in <af879d82b0fe4cf8b1d541279e6c3414#0835d9c74997d27a0e543614112fcf97>:0 \n  at LumiDocTalk.ViewModel.VoipView_Model.ConnectXmppServer (System.String username, System.String password) <0x102ba6490 + 0x008bf> in <8a5d829cabcf4ba38d7fff223dc2c7f5#0835d9c74997d27a0e543614112fcf97>:0 ",
    "wrapperSdkName": "appcenter.xamarin"
  },
  "appId": "0dbe2aac-d460-40c0-b8f7-d9d3254b8f7c",
  "installId": "0B2BAEF7-5924-41AD-8789-1924E71E5E2F",
  "isTestMessage": false,
  "timestamp": "2021-07-02T20:59:30.639Z",
  "sid": "0a528ea5-884e-47d6-a4eb-a6643720fe69",
  "device": {
    "sdkName": "appcenter.ios",
    "sdkVersion": "4.1.1",
    "wrapperSdkVersion": "4.2.0",
    "wrapperSdkName": "appcenter.xamarin",
    "model": "iPhone12,3",
    "oemName": "Apple",
    "osName": "iOS",
    "osVersion": "14.6",
    "osBuild": "18F72",
    "locale": "en_PK",
    "timeZoneOffset": 300,
    "screenSize": "2436x1125",
    "appVersion": "10.0",
    "appBuild": "0.0.0.5",
    "appNamespace": "----------",
    "wrapperRuntimeVersion": "12.6.0"
  }
}

Ways to close existing connections + WebSocket dispose issues

Hi, this issue concerns a few things:

  1. Is there a way to disconnect an existing XMPPWebSocketConnection or XmppTcpConnection and reopen them later? I don't see methods exposing some of these.
  2. XMPPWebSocketConnection does not override Dispose to dispose the WebSocket object. This may result in memory leaks.

Connecition Failed Event

Hi,

I am looking to catch the ConnectionFailed Event but it does work as I expected.
I am using this library in my chat app using Xamarin Forms, It is working perfectly fine.
I noticed that when app at background for sometime so app disconnect from the xmpp server.
Now I wanted to know is there any way I can check the XmppClient connection state so that would help me see the connection state of the XmppClient to achieve the desired task.

Thanks

System.ArgumentException: An XObject cannot be used as a value.

  1. Create new .NET Core project.
  2. Install SharpXMPP.Shared:
    <PackageReference Include="SharpXMPP.Shared" Version="0.0.1-pre02" />
  3. Write the following code:
    var x = new XMPPMessage();
    x.Text = "hello world";
  4. When ran, it will throw the following exception:
    System.ArgumentException: An XObject cannot be used as a value.
       at System.Xml.Linq.XContainer.GetStringValue(Object value)
       at System.Xml.Linq.XElement.SetValue(Object value)
       at SharpXMPP.XMPP.Client.Elements.XMPPMessage.set_Text(String value)
    

Connection cancellation token is ignored

We have a nice api XmppTcpConnection::ConnectAsync(CancellationToken), but the token is completely ignored there.

This breaks an ability to cancel the connection.

PRECIS Support (RFC7564)

Currently SharpXMPP may not work properly with non-ASCII symbols in JIDs and passwords, they should be normalised as described in RFC7564

Cannot connect to some servers

For example, I'm trying to connect as [email protected], and it unfortunately tells me:

System.ArgumentException: None of the discovered or specified addresses match the socket address family.
Parameter name: addresses
   at System.Net.Sockets.Socket.BeginConnect(IPAddress[] addresses, Int32 port, AsyncCallback requestCallback, Object state)
   at System.Net.Sockets.TcpClient.BeginConnect(IPAddress[] addresses, Int32 port, AsyncCallback requestCallback, Object state)
   at System.Net.Sockets.TcpClient.<>c.<ConnectAsyncCore>b__64_0(IPAddress[] targetAddresses, Int32 targetPort, AsyncCallback callback, Object state)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl[TArg1,TArg2](Func`5 beginMethod, Func`2 endFunction, Action`1 endAction, TArg1 arg1, TArg2 arg2, Object state, TaskCreationOptions creationOptions)
   at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2](Func`5 beginMethod, Action`1 endMethod, TArg1 arg1, TArg2 arg2, Object state)
   at System.Net.Sockets.TcpClient.ConnectAsyncCore(IPAddress[] addresses, Int32 port)
   at SharpXMPP.XmppTcpConnection.<Connect>d__15.MoveNext()

Publish to NuGet

We need to set up NuGet publishing infrastructure and maybe even publish the first preview release.

Send friend request

Hi,

var roast = client.RosterManager.Roster;

Even at backend I have two friends in roster but this method always return 0
Secondly is there any way I can catch the roaster updates.

Thanks

File Upload

Hi,

Please guys help me how can I do FileUploading.

Simple IQ creation and send Message Example

Where can I find a simple example of creating a message to send?

SharpXMPP.XMPP.JID servjid = new SharpXMPP.XMPP.JID()
{
    User = user, Domain = server, Resource = Environment.MachineName
};

var xmppClient = new SharpXMPP.XmppClient(servjid, pass, false);

// Do I have to create the XML or is there methods to do it?
xmppClient.sxmppClient.Send(?????????);

NullReferencexception in InfoHandler

Object reference not set to an instance of an object.
   at SharpXMPP.XMPP.Stanza.Parse[T](XElement src)
   at SharpXMPP.XMPP.Client.Disco.InfoHandler.Handle(XmppConnection connection, XMPPIq element)
   at SharpXMPP.XMPP.Client.IqManager.<>c__DisplayClass3_0.<Handle>b__0(PayloadHandler h)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at SharpXMPP.XMPP.Client.IqManager.Handle(XmppConnection sender, XMPPIq element)
   at SharpXMPP.XmppConnection.OnIq(XMPPIq e)
   at SharpXMPP.XmppTcpConnection.SessionLoop()

XEP-0363: HTTP File Upload

Hi,

I am using ejabberd with this client library in Xamarin Forms and pretty happy so far.
I am looking for File upload but this feature is not available in library. Can you please help me out or if any resources which are helpful so please share with me.
I have configured Rest api of ejabberd but not able to find the file upload api.
Please guide me is there any resource that help me to achieve this behavior.

Thanks

`XmppConnection` `Capabilities` what is this for?

Hi.

What's the use of Capabilities why does it creates a Node http://bggg.net.ru/caps ?

Code from SharpXMPP.Shared/XmppConnection.cs

protected XmppConnection(string ns)
{
    queries = new Dictionary<string, Action<XMPPIq>>();
    _ns = ns;
    Capabilities = new CapabilitiesManager
    {
        Identity = new Identity
        {
            Category = "client",
            IdentityType = "mobile",
            IdentityName = "SharpXMPP"
        },

        Node = "http://bggg.net.ru/caps",
        Features = new List<string>
        {
            Namespaces.DiscoInfo,
            Namespaces.DiscoItems
        }
    };

    IqManager = new IqManager
    {
        PayloadHandlers =
        {
            new InfoHandler(Capabilities),
            new ItemsHandler()
        }
    };
    Iq += IqManager.Handle;
}

Account registration and roster management

Hi all,

I'm new for Xamarin chat app. I find a function in this project. How to use XmppRegisterHandler.cs to register a new account ? Also need add/remove roster, thanks.

XmppWebSocketConnection class

Currently the compilation of XmppSocketConnection class is disabled. I had to disable it in scope of .NET Core porting, because it uses WebSocket4Net, but there's no WebSocket4Net dependency in the project and I had no time to address that properly.

What should we do now? There's an issue #6. @vitalyster, do you have plans to revive this class in its scope?

XEPs and RFCs support page with version

XMPP RFC supports

Custom IQ handlers

Say I want to add a custom IQ handler (e.g. for XMPP Ping or whatever).

Currently, we offer no way for the user to add such handler, since we recreate the IQManager every time we need to handle an IQ query, and it is no ability to override it from the user side:

Iq += (sender, iq) => new IqManager(this)
{
PayloadHandlers = new List<PayloadHandler>
{
new InfoHandler(Capabilities),
new ItemsHandler()
}
}.Handle(iq);

private void OnIqHandler(XmppConnection sender, XMPPIq iq)
{
new IqManager(this)
{
PayloadHandlers = new List<PayloadHandler>
{
new InfoHandler(Capabilities),
new ItemsHandler()
}
}.Handle(iq);
}

Connection termination

  1. Connect to an XMPP server
  2. Shut down the server (Prosody in my case)
  3. The server will properly close the XML stream
  4. But the client won't detect it

The reason is in this line of code:

Prosody closes the XML correctly, thus it will just start returning false in loop instead of trying to read more from the stream and failing.

Message with custom fields/attributes

Hi.,

I am looking to add some custom fields into XMPPMessage. Its pretty simple to modify the project and add custom fields but is there any way out there to add custom field with the existing XMPPMessage class and use it without modifying the code. Or is there any possibility to send message by setting custom attributes and process the attribute value on receiving end.
Like this

        var message = new XMPPMessages
        {   
            ID=Guid.NewGuid().ToString(),
            Text = "Hi",
            To = new JID("[email protected]")
        };
        message.SetAttributeValue("type", "Urgent");
      Client.Send(message)

Connection Error in Xamarin Forms

Hi

I am using ejabberd server and connecting through the static ip of the server , It is working fine in windows and console apps but on Xamarin forms I am not able to even connect both in android and iOS.

This is error on Android.

at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Boolean runSynchronously, Mono.Net.Security.MonoSslAuthenticationOptions options, System.Threading.CancellationToken cancellationToken) [0x0025c] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:310
at SharpXMPP.XmppTcpConnection.InitTlsIfSupported (SharpXMPP.XMPP.Stream.Elements.Features features) [0x000bf] in <4f194704292d40ad8605a7be061cbf71>:0
at SharpXMPP.XmppTcpConnection.ConnectAsync (System.Threading.CancellationToken token) [0x00160] in <4f194704292d40ad8605a7be061cbf71>:0
at LumiDocTalk.Views.Dashboard.OnAppearing () [0x00274] in /Volumes/MySSD/Projects/LumiMobile/LumiDocTalk/LumiDocTalk/LumiDocTalk/Views/Dashboard.xaml.cs:58

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.