Expand|Select|Wrap|Line Numbers
- Private Sub winsock_DataReceived(ByVal sender As TCPConnection, ByVal Data As String, ByVal BytesReceived As Long) Handles winsock.DataReceived
- If InStr(Data, "<PUPA>") > 0 Then
- SetServerKey(Data)
- CreateLoginInformation()
- ElseIf InStr(Data, "<LIGO>") Then
- frmMain.Show()
- frmLogin.Hide()
- End If
- End Sub
Expand|Select|Wrap|Line Numbers
- Private Sub BuildString(ByVal Bytes() As Byte, ByVal offset As Integer, ByVal count As Integer)
- Dim intIndex As Integer
- Dim txt As String
- 'Console.WriteLine("BuildString")
- m_State = 2
- objText = New StringBuilder()
- For intIndex = offset To offset + count - 1
- txt = ChrW(Bytes(intIndex))
- objText.Append(txt)
- Next
- RaiseEvent DataReceived(Me, objText.ToString, objText.Length)
- m_State = 1
- End Sub
Expand|Select|Wrap|Line Numbers
- Private Sub Receive(ByVal ar As IAsyncResult)
- ' Start the data receiving process
- Dim intCount As Integer
- Console.WriteLine("Received")
- Try
- SyncLock objClient.GetStream
- intCount = objClient.GetStream.EndRead(ar)
- End SyncLock
- If intCount < 1 Then
- RaiseEvent Disconnected(Me)
- m_State = 0
- Exit Sub
- End If
- BuildString(arData, 0, intCount)
- SyncLock objClient.GetStream
- objClient.GetStream.BeginRead(arData, 0, 1024, AddressOf Receive, Nothing)
- End SyncLock
- Catch e As Exception
- RaiseEvent SockError(e.Message.ToString)
- RaiseEvent Disconnected(Me)
- m_State = 0
- End Try