use more inherit features

This commit is contained in:
schedpas
2020-06-09 07:49:31 +02:00
parent 49e45e50cd
commit 6e33874df6
4 changed files with 33 additions and 32 deletions

View File

@@ -44,33 +44,20 @@ Public Class TCPManager
tcp.ReceiveBufferSize = BufferSize
Stream.Read(buf, 0, buf.Length)
Dim contentstring As String = Text.Encoding.Default.GetString(buf)
Dim content As Object = Nothing
Dim cmd As String = String.Empty
Try
Dim res = DecodeFromBytes(buf)
cmd = res.cmd
content = res.content
Catch ex As Exception
End Try
tcp.Close()
RaiseRetriveData(ip, cmd, content)
ProcessRetrivedData(ip, buf)
End If
Loop
End Sub
Public Overrides Sub Send(empfängerIP As String, cmd As String, content As Object)
Dim ep As New IPEndPoint(GetIPFromHost(empfängerIP).MapToIPv4, Port)
Protected Overrides Sub SendData(ep As IPEndPoint, buf As Byte())
Dim tcp As New TcpClient
tcp.SendBufferSize = BufferSize
tcp.Connect(ep)
Dim stream As NetworkStream = tcp.GetStream()
Dim buf As Byte() = EncodeToBytes(cmd, content, UseAssemblyQualifiedName)
'Send Data
stream.Write(buf, 0, buf.Length)