Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
girish venkata #1
User title: Girish Venkata
Member since Nov 2017 · 5 posts
Group memberships: Members
Show profile · Link to this post
Subject: Matrix vNext
Hey Alex,

We are using Matrix vNext package in .Net Standard project. We are able to connect to server and send message. But we don't find documentation on how to receive message. It would be great if you post some sample regarding this. Below is code snippet we are using just for reference.

  1.   App.xmppClient = new XmppClient();
  2.             App.xmppClient.Username = "XXXX";
  3.             App.xmppClient.Password = "password";
  4.             App.xmppClient.XmppDomain = "XXXX-XXX-XX.sobis.com";
  5.             if (Device.OS == TargetPlatform.Windows)
  6.             {
  7.                 App.xmppClient.HostnameResolver = new StaticNameResolver(IPAddress.Parse("X.X.X.X"), 5222);
  8.                 App.xmppClient.Port = 5222;
  9.                 App.xmppClient.Tls = false;
  10.             }
  11.             App.xmppClient.CertificateValidator = new AlwaysAcceptCertificateValidator();
  12.             await App.xmppClient.ConnectAsync();
  13.             await App.xmppClient.SendPresenceAsync(Show.Chat, "free for chat");
  14.             var msg = new Matrix.Xmpp.Client.Message { Type = MessageType.Chat, To = "XX@XXXX-XXX-XX.sobis.com", Body = "Message hello" };
  15.             await App.xmppClient.SendAsync(msg);
This post was edited on 2017-11-06, 10:34 by Alex.
Edit reason: added code formatting
Avatar
Alex #2
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
You have to subscribe to the XmppXElement stream using the Reactive Extensions (Rx).

This snippet subscribes you to all incoming message stanzas. When you are interested at only specific type of messages, or messages from specific users you can define this over Linq and the predicate.

  1. xmppClient
  2.     .XmppXElementStreamObserver
  3.     .Where(el => el is Message)
  4.     .Subscribe(el =>
  5.     {
  6.         System.Diagnostics.Debug.WriteLine(el.ToString());
  7.     });
Avatar
girish venkata #3
User title: Girish Venkata
Member since Nov 2017 · 5 posts
Group memberships: Members
Show profile · Link to this post
Subject: How to remove a participant from chat room?
does Matrix vNext support removing of user from group chat ? if yes please let us know how to do it
Avatar
Alex #4
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
don't mix subjects in a single thread please. Open new threads instead then please.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS