Not logged in. · Lost password · Register
Forum: MatriX RSS
AgentSmithers #1
Member since Nov 2019 · 2 posts
Group memberships: Members
Show profile · Link to this post
Subject: Anyone have a Vb.net sample of how to connect the callback to discover rooms
Anyone have a Vb.net sample of how to connect the callback to discover rooms?
I have a snippet that works u to that point but the way i need to handle adding my call back is given me some hurdles. Anyone have a sample?



  1. Imports Matrix
  2. Imports Matrix.Xmpp
  3. Imports Matrix.Xmpp.Client
  4. Imports Matrix.Xmpp.Roster
  5. 'Install-Package MatriX
  6. Module Module1
  7.     'Install-Package MatriX
  8.     WithEvents MyXmppClient As New XmppClient()
  9.     WithEvents myMuch As MucManager
  10.     Sub Main()
  11.  
  12.         MyXmppClient.Compression = False
  13.         MyXmppClient.Hostname = Nothing
  14.         MyXmppClient.ResolveSrvRecords = True
  15.         MyXmppClient.StartTls = True
  16.         MyXmppClient.Status = "Online"
  17.         MyXmppClient.Show = Show.None
  18.  
  19.         MyXmppClient.Transport = Matrix.Net.Transport.Socket
  20.         MyXmppClient.SetUsername("jid")
  21.         MyXmppClient.SetXmppDomain("domain.com")
  22.         MyXmppClient.Password = "MyPas$"
  23.         MyXmppClient.ResolveSrvRecords = False
  24.         MyXmppClient.Hostname = "Cupser.domain.com"
  25.  
  26.         MyXmppClient.Show = Matrix.Xmpp.Show.Chat
  27.  
  28.         MyXmppClient.AutoRoster = True
  29.         MyXmppClient.AutoReplyToPing = True
  30.         MyXmppClient.AutoPresence = True
  31.  
  32.         ''xmppClient.MessageFilter.Add(new Jid(JID_Receiver), new BareJidComparer(), new EventHandler<MessageEventArgs>(XmppClient_OnMessage), null);
  33.         Try
  34.             MyXmppClient.Open()
  35.         Catch ex As System.Net.WebException
  36.             Console.WriteLine(ex.Message)
  37.         Catch ex As Exception
  38.             Console.WriteLine(ex.Message)
  39.         End Try
  40.  
  41.         Console.ReadKey()
  42.  
  43.         MyXmppClient.Close()
  44.     End Sub
  45.  
  46.     Private Sub DiscoItemsResult(ByVal sender As Object, ByVal e As IqEventArgs)
  47.         Dim foo = "asdfsadf"
  48.     End Sub
  49.  
  50.     Private Sub xmppClient_OnInitialPresence(sender As Object, e As PresenceEventArgs) Handles MyXmppClient.OnInitialPresence
  51.         Debug.WriteLine("xmppClient_OnInitialPresence")
  52.         myMuch = New MucManager(MyXmppClient)
  53.         'Debug.WriteLine(MyXmppClient.Send(New Message(New Jid("jid"), MessageType.Chat, "Test")))
  54.  
  55.         Dim Mysd As New DiscoManager(MyXmppClient)
  56.         'DiscoManager.DiscoverItems("conference-2-standalonecluster32150.emc.org", "jid@emc.org", New EventHandler(Of IqEventArgs)(AddressOf DiscoItemsResult))
  57.         'Mysd.DiscoverInformation()
  58.         Dim Room As String = "chat552951691316913@conference-2-standalonecluster32150.emc.org"
  59.         myMuch.EnterRoom(Room, "nickname")
  60.         'myMuch.roo
  61.         'Dim Addressto As New EventHandler(AddressOf RequestMemberListFunc)
  62.         'Dim Addressto As New RequestMemberListCB2(AddressOf RequestMemberListFunc)
  63.  
  64.         'myMuch.RequestMemberList(Room, Addressto)
  65.         'Debug.WriteLine(MyXmppClient.Send(New Message(New Jid(Room), MessageType.GroupChat, "Disregard that thanks.")))
  66.         ' myMuch.ExitRoom(Room, "NickName")
  67.     End Sub
  68.  
  69.     Delegate Sub eventhandler2(events As IqEventArgs)
  70.     Delegate Sub RequestMemberListCB2(sender As Object, e As PresenceEventArgs)
  71.  
  72.     Private Sub RequestMemberListFunc(sender As Object, e As PresenceEventArgs)
  73.         'Console.WriteLine("RequestMemberListFunc: " & events.Iq.Name.LocalName)
  74.     End Sub
  75.     Private Sub RequestMemberListFunc2(sender As Object, e As EventArgs)
  76.         Console.WriteLine("xmppClient_OnLogin: " & e.State)
  77.     End Sub
  78.  
  79.  
  80.     Private Sub xmppClient_OnLogin(sender As Object, e As EventArgs) Handles MyXmppClient.OnLogin
  81.         Console.WriteLine("xmppClient_OnLogin: " & e.State)
  82.     End Sub
  83.  
  84.     Private Sub xmppClient_OnMessage(sender As Object, e As MessageEventArgs) Handles MyXmppClient.OnMessage
  85.         Console.WriteLine(e.Message)
  86.  
  87.         If (e.Message.Body <> Nothing) Then
  88.             Console.ForegroundColor = ConsoleColor.Yellow
  89.             Console.WriteLine("{0}: {1}", e.Message.From.User, e.Message.Body)
  90.             Console.Write("{0}: ", e.Message.To.User)
  91.  
  92.  
  93.             If e.Message.Error IsNot Nothing Then
  94.                 Console.ForegroundColor = ConsoleColor.Red
  95.                 Console.WriteLine(e.Message.Error)
  96.             Else
  97.                 'MyXmppClient.Send(New Message(New Jid(e.Message.From.Bare), MessageType.Chat, e.Message.Body))
  98.             End If
  99.             Console.ForegroundColor = ConsoleColor.Green
  100.         End If
  101.     End Sub
  102.  
  103.     Private Sub xmppClient_OnPresence(sender As Object, e As PresenceEventArgs) Handles MyXmppClient.OnPresence
  104.         Console.ForegroundColor = ConsoleColor.White
  105.         Console.WriteLine("Online Contacts: ")
  106.         If (Not e.Presence.Type.Equals("unavailable")) Then
  107.             Console.WriteLine("{0}@{1}  {2}", e.Presence.From.User, e.Presence.From.Server, e.Presence.Type)
  108.             Console.WriteLine()
  109.         End If
  110.         Console.WriteLine(e.Presence)
  111.     End Sub
  112.  
  113.     Private Sub xmppClient_OnRosterItem(sender As Object, e As RosterEventArgs) Handles MyXmppClient.OnRosterItem
  114.         Console.WriteLine(e.RosterItem.ToString & " - " & e.Version)
  115.     End Sub
  116.  
  117.     Private Sub xmppClient_OnStreamStart(sender As Object, e As StanzaEventArgs) Handles MyXmppClient.OnStreamStart
  118.         Debug.WriteLine("OnStreamStart")
  119.     End Sub
  120.  
  121.     Private Sub myMuch_OnInvite(sender As Object, e As MessageEventArgs) Handles myMuch.OnInvite
  122.         Debug.WriteLine("OnInvite: " & e.Message.ToString)
  123.     End Sub
  124. End Module
This post was edited on 2019-11-14, 08:39 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4363 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
can you please give me more details?
What the exact problem? Can you point me to the line number in your sample?

Alex
AgentSmithers #3
Member since Nov 2019 · 2 posts
Group memberships: Members
Show profile · Link to this post
Yes between lines 61 to 77 were my attempts to create the callback but with no success sadly.
My goal is just to discover the public rooms on our jabber server.
Avatar
Alex #4
Member since Feb 2003 · 4363 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
here you can see an example how the callack work in general. Its this sample its for vcards:
https://gitlab.com/matrix-xmpp/samples/blob/master/vb/Mini…

Why are you not using the new async/await functionality? This is much easier to use, makes code simpler and easier to maintain.

Alex
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