update pilz lib

This commit is contained in:
2019-10-18 10:32:12 +02:00
parent 3d41662b26
commit 1d640d2352
3 changed files with 5 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ Public MustInherit Class ConnectionManagerBase
Private listening As Boolean = False
Public ReadOnly Property Port As Integer
Public Property UseAssemblyQualifiedName As Boolean = False
Public Event RetriveData(manager As ConnectionManagerBase, senderIP As String, cmd As String, content As Object)
@@ -42,14 +43,14 @@ Public MustInherit Class ConnectionManagerBase
RaiseEvent RetriveData(Me, senderIP, cmd, content)
End Sub
Protected Shared Function EncodeToBytes(cmd As String, content As Object) As Byte()
Protected Shared Function EncodeToBytes(cmd As String, content As Object, useAssemblyQualifiedName As Boolean) As Byte()
Dim ms As New MemoryStream()
Dim bw As New BinaryWriter(ms)
Dim obj As New JObject
'Write header
obj("Cmd") = cmd
obj("ContentType") = content?.GetType?.ToString
obj("ContentType") = If(useAssemblyQualifiedName, content?.GetType?.AssemblyQualifiedName, content?.GetType?.ToString)
'Content
obj("Content") = JToken.FromObject(content)

View File

@@ -70,7 +70,7 @@ Public Class TCPManager
tcp.Connect(ep)
Dim stream As NetworkStream = tcp.GetStream()
Dim buf As Byte() = EncodeToBytes(cmd, content)
Dim buf As Byte() = EncodeToBytes(cmd, content, UseAssemblyQualifiedName)
'Send Data
stream.Write(buf, 0, buf.Length)

View File

@@ -83,7 +83,7 @@ Public Class UDPManager
Public Overrides Sub Send(empfängerIP As String, cmd As String, content As Object)
Dim ep As New IPEndPoint(GetIPFromHost(empfängerIP).MapToIPv4, Port)
Dim udp As New UdpClient
Dim buf As Byte() = EncodeToBytes(cmd, content)
Dim buf As Byte() = EncodeToBytes(cmd, content, UseAssemblyQualifiedName)
udp.Connect(ep)
udp.Send(buf, buf.Length)