update pilz lib
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user