Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Private WithEvents wsClient As New SocketsClient()
- Private Sub AT(ByVal Text As String)
- txtChat.AppendText(Text & vbCrLf)
- txtChat.ScrollToCaret()
- End Sub
- Private Sub IRC_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
- AT("Attempting connection to host...")
- wsClient.Connect("irc.gamesurge.net", 6667)
- End Sub
- Private Sub wsClient_onConnect() Handles wsClient.onConnect
- AT("Connected to server.")
- wsClient.SendData(wsClient.StringToBytes("JOIN #epicwow" + vbCrLf))
- wsClient.SendData(wsClient.StringToBytes("NICK ZePhluck" & vbCrLf))
- wsClient.SendData(wsClient.StringToBytes("USER MyTester localhost 0.0.0.0: Created in VB.net" & vbCrLf))
- End Sub
- Private Sub wsClient_onError(ByVal Description As String) Handles wsClient.onError
- AT("Error: " & Description)
- End Sub
- Private Sub wsClient_onDataArrival(ByVal Data() As Byte, ByVal totBytes As Integer) Handles wsClient.onDataArrival
- Dim inData As String = wsClient.BytestoString(Data)
- Dim lData() As String
- Dim C() As String
- Dim tData As Integer
- Dim CL As Integer
- Dim CLi As String
- Dim a As Integer
- lData = Split(inData, Chr(10))
- tData = UBound(lData) - LBound(lData)
- For a = 0 To tData
- If Mid(lData(a), 1, 1) = ":" Then
- lData(a) = Mid(lData(a), 2)
- End If
- Next
- For CL = 0 To tData
- C = Split(lData(CL), " ")
- ReDim Preserve C(2000)
- CLi = lData(CL)
- If C(0) = "PING" Then
- wsClient.SendData(wsClient.StringToBytes("PONG :" & Mid(C(1), 2) & vbCrLf))
- End If
- AT(CLi)
- Next
- End Sub
- Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtSend.KeyPress
- If Asc(e.KeyChar) = 13 Then
- wsClient.SendData(wsClient.StringToBytes(txtSend.Text & vbCrLf))
- 'txtSend.SelectAll()
- End If
- End Sub
- Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
- wsClient.SendData(wsClient.StringToBytes(txtSend.Text & vbCrLf))
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement