Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[.Net] Matrix (XMPP) Library
14-07-2012, 06:09 PM, (This post was last modified: 14-07-2012, 07:05 PM by fatah.)
Post: #1
[.Net] Matrix (XMPP) Library
In a boring day, want to share something. GayFace

Patched Library:
http://uploading.com/files/get/5e58d9e3/Matrix.7z

Patch using .Net Reflector & Reflexil. Clean patch.

Sample XMPP support for:
1. Google Talk
2. Facebook Chat
3. MSN
4. Other services using XMPP protocol

Reference & Documentation:
http://www . ag - software . de/ matrix -xmpp-sdk/

Sample Code For GTalk:
Code:
Option Explicit On
Option Strict On

Imports Matrix.Xmpp.Client

Class Roaster
    Private _No As Integer
    Private _FullName As String
    Private _Id As String

    Public Sub New(No As Integer, FullName As String, Id As String)
        _No = No
        _FullName = FullName
        _Id = Id
    End Sub

    Public Property No As Integer
        Get
            Return _No
        End Get
        Set(value As Integer)
            _No = value
        End Set
    End Property

    Public Property FullName As String
        Get
            Return _FullName
        End Get
        Set(value As String)
            _FullName = value
        End Set
    End Property

    Public Property Id As String
        Get
            Return _Id
        End Get
        Set(value As String)
            _Id = value
        End Set
    End Property
End Class

Class MainWindow

    Private No As Integer
    Private WithEvents _xmppClient As XmppClient

    Private Sub MainWindow_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        _xmppClient = New XmppClient

        _xmppClient.SetUsername("gtalkusername")
        _xmppClient.SetXmppDomain("gmail.com")
        _xmppClient.Password = "gtalkpassword"

        _xmppClient.ResolveSrvRecords = False
        _xmppClient.Transport = Matrix.Net.Transport.Socket
        _xmppClient.Hostname = "talk.google.com"

        _xmppClient.Status = "Testing XMPP library"
        _xmppClient.Show = Matrix.Xmpp.Show.chat

        _xmppClient.AutoReplyToPing = True

        lblStatus.Text = "Connecting..."
        _xmppClient.Open()
    End Sub

    Private Sub MainWindow_Unloaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Unloaded
        _xmppClient.Close()
    End Sub

    Private Sub _xmppClient_OnMessage(sender As Object, e As Matrix.Xmpp.Client.MessageEventArgs) Handles _xmppClient.OnMessage
        MsgBox("Message From: " & e.Message.From.Bare & vbCrLf & vbCrLf & e.Message.Body)
    End Sub


    Private Sub _xmppClient_OnRosterEnd(sender As Object, e As Matrix.EventArgs) Handles _xmppClient.OnRosterEnd
        lblStatus.Text = "Ready"
        Trace.WriteLine("OnRosterEnd")
    End Sub

    Private Sub _xmppClient_OnRosterItem(sender As Object, e As Matrix.Xmpp.Roster.RosterEventArgs) Handles _xmppClient.OnRosterItem
        Dim FullName As String = ""
        Dim Id As String = ""

        Id = e.RosterItem.Jid.Bare

        Trace.Write(e.RosterItem.FirstAttribute.Value.ToString)
        If e.RosterItem.Name IsNot Nothing Then
            Trace.Write(" - " & e.RosterItem.Name.ToString)
            FullName = e.RosterItem.Name.ToString
        End If
        Trace.WriteLine("")

        Dim _Row As New Roaster(No, FullName, Id)
        lvRoaster.Items.Add(_Row)
        No = No + 1
    End Sub

    Private Sub _xmppClient_OnRosterStart(sender As Object, e As Matrix.EventArgs) Handles _xmppClient.OnRosterStart
        No = 1
        lblStatus.Text = "Getting contact list..."
        Trace.WriteLine("OnRosterStart")
    End Sub

    Private Sub btnTest_Click(sender As Object, e As System.Windows.RoutedEventArgs) Handles btnTest.Click
        Dim msg As New Matrix.Xmpp.Client.Message
        msg.Type = Matrix.Xmpp.MessageType.chat
        msg.To = New Matrix.Jid(txtId.Text.ToString)
        msg.Body = txtMessage.Text.ToString
        _xmppClient.Send(msg)
    End Sub

    Private Sub lvRoaster_SelectionChanged(sender As Object, e As System.Windows.Controls.SelectionChangedEventArgs) Handles lvRoaster.SelectionChanged
        txtId.Text = CType(CType(sender, ListView).SelectedItem, Roaster).Id
    End Sub
End Class
̿ ̿ ̿̿'̿̿\̵͇̿̿\=(•̪●)=/̵͇̿̿/'̿̿ ̿ ̿ ̿ - انا کڤيتݢولوڠ
http://fatah.afraid.org/
[Image: 763440762.png]
Reply
01-05-2013, 01:52 AM,
Post: #2
RE: [.Net] Matrix (XMPP) Library
cm mna nk gna bro?
Reply


Forum Jump: