Imports System.Net
Public Class Form1
Private Sub login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles login.Click
Winsock.Connect()
Winsock.RemoteHost = "openfire.nimbuzz.com"
Winsock.RemotePort = 5222
End Sub
Private Sub Winsock_ConnectionRequest(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_ConnectionRequestEvent) Handles Winsock.ConnectionRequest
Winsock.Accept(e.requestID)
txtserver.Text = txtserver.Text & Winsock.RemoteHost & ":" & Winsock.RemotePort & " has connected."
End Sub
Private Sub Winsock_ConnectEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles Winsock.ConnectEvent
Winsock.SendData("<stream:stream to='nimbuzz.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>")
End Sub
Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Dim data As String
Winsock.GetData(data)
data = Replace(data, """", "'")
If InStr(data, "<stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><compression xmlns='http://jabber.org/features/compress'><method>zlib</method></compression><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism></mechanisms><register xmlns='http://jabber.org/features/iq-register'/></stream:features>") Then
Winsock.SendData("<iq type='set' xml:lang='en' id='NLgn' to='nimbuzz.com'><query xmlns='jabber:iq:auth'><username>" & txtUserID.Text & "</username><password>" & txtPass.Text & "</password><resource>" & txtResource.Text & "-bawor" & "</resource></query></iq>")
End If
If InStr(data, "<iq type='result' from='nimbuzz.com' xml:lang='en' id='NLgn'/>") Then
MessageBox.Show("Logged in")
End If
If InStr(data, "<iq type='error' from='nimbuzz.com' xml:lang='en' id='NLgn'><query xmlns='jabber:iq:auth'><username>" & txtUserID.Text & "</username><password>" & txtPass.Text & "</password><resource>" & txtResource.Text & "-bawor" & "</resource></query><error code='401' type='auth'><not-authorized xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>") Then
MessageBox.Show("Loggin Failed")
End If
End Sub
End Class

New Topic/Question
Reply



MultiQuote


|