Advertisement
Guest User

Frm1

a guest
Aug 18th, 2011
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. Public Class Form1
  2.  
  3. Private WithEvents wsClient As New SocketsClient()
  4.  
  5. Private Sub AT(ByVal Text As String)
  6. txtChat.AppendText(Text & vbCrLf)
  7. txtChat.ScrollToCaret()
  8. End Sub
  9.  
  10. Private Sub IRC_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
  11. AT("Attempting connection to host...")
  12. wsClient.Connect("irc.gamesurge.net", 6667)
  13. End Sub
  14.  
  15. Private Sub wsClient_onConnect() Handles wsClient.onConnect
  16. AT("Connected to server.")
  17.  
  18. wsClient.SendData(wsClient.StringToBytes("JOIN #epicwow" + vbCrLf))
  19. wsClient.SendData(wsClient.StringToBytes("NICK ZePhluck" & vbCrLf))
  20. wsClient.SendData(wsClient.StringToBytes("USER MyTester localhost 0.0.0.0: Created in VB.net" & vbCrLf))
  21.  
  22. End Sub
  23.  
  24. Private Sub wsClient_onError(ByVal Description As String) Handles wsClient.onError
  25. AT("Error: " & Description)
  26. End Sub
  27.  
  28. Private Sub wsClient_onDataArrival(ByVal Data() As Byte, ByVal totBytes As Integer) Handles wsClient.onDataArrival
  29. Dim inData As String = wsClient.BytestoString(Data)
  30.  
  31. Dim lData() As String
  32. Dim C() As String
  33. Dim tData As Integer
  34. Dim CL As Integer
  35. Dim CLi As String
  36. Dim a As Integer
  37.  
  38. lData = Split(inData, Chr(10))
  39. tData = UBound(lData) - LBound(lData)
  40.  
  41. For a = 0 To tData
  42. If Mid(lData(a), 1, 1) = ":" Then
  43. lData(a) = Mid(lData(a), 2)
  44. End If
  45. Next
  46.  
  47. For CL = 0 To tData
  48. C = Split(lData(CL), " ")
  49. ReDim Preserve C(2000)
  50. CLi = lData(CL)
  51.  
  52. If C(0) = "PING" Then
  53. wsClient.SendData(wsClient.StringToBytes("PONG :" & Mid(C(1), 2) & vbCrLf))
  54. End If
  55.  
  56. AT(CLi)
  57. Next
  58. End Sub
  59. Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtSend.KeyPress
  60. If Asc(e.KeyChar) = 13 Then
  61. wsClient.SendData(wsClient.StringToBytes(txtSend.Text & vbCrLf))
  62. 'txtSend.SelectAll()
  63. End If
  64. End Sub
  65.  
  66. Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
  67. wsClient.SendData(wsClient.StringToBytes(txtSend.Text & vbCrLf))
  68. End Sub
  69. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement