summaryrefslogtreecommitdiff
path: root/CSharp/Ivy/IvyPPC/IvyUDPStreamV3.cs
diff options
context:
space:
mode:
Diffstat (limited to 'CSharp/Ivy/IvyPPC/IvyUDPStreamV3.cs')
-rw-r--r--CSharp/Ivy/IvyPPC/IvyUDPStreamV3.cs26
1 files changed, 18 insertions, 8 deletions
diff --git a/CSharp/Ivy/IvyPPC/IvyUDPStreamV3.cs b/CSharp/Ivy/IvyPPC/IvyUDPStreamV3.cs
index 027789a..99fb87c 100644
--- a/CSharp/Ivy/IvyPPC/IvyUDPStreamV3.cs
+++ b/CSharp/Ivy/IvyPPC/IvyUDPStreamV3.cs
@@ -22,7 +22,7 @@ namespace IvyBus
}
/*
* message Syntax:
- * this is a binary formated message use of network representation
+ * this is a text formated message
*
* message Format:
protocol_version, TCP server port , appId, appName
@@ -55,6 +55,7 @@ namespace IvyBus
read = input.Read();
if (read < 0)
throw new EndOfStreamException();
+ if (read == 0) break;
car = (char)read;
if (car != sep)
str.Append(car);
@@ -64,12 +65,21 @@ namespace IvyBus
internal override void Deserialize(out ushort version, out ushort port, out string appId, out string appName)
{
+ version = 0;
+ port = 0;
+ appId = "";
+ appName = "";
+ try {
version = DeserializeShort();
port = DeserializeShort();
- //appId = DeserializeString(); //No AppId in V3
- //appName = DeserializeString('\n');
- appId = "";
- appName = "";
+ //Optionel in V3 protocol depend on client version
+ appId = DeserializeString(' ');
+ appName = DeserializeString('\n');
+ }
+ catch( EndOfStreamException e )
+ {
+ // Bad protocol message receive or without appId and appName
+ }
}
private void Serialize(ushort arg, char sep)
{
@@ -84,9 +94,9 @@ namespace IvyBus
internal override void Serialize(ushort port, string appId, string appName)
{
Serialize(PROCOCOLVERSION, ' ');
- Serialize(port,'\n');
- //Serialize(appId); //No AppId in V3
- //Serialize(appName, '\n'); //No Appname in V3
+ Serialize(port,' ');
+ Serialize(appId,' '); //No AppId in V3
+ Serialize(appName, '\n'); //No Appname in V3
output.Flush();
}
}