From 897f096134acc7a5ecf2ee4e56eac87b9e97c807 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 09:51:03 +0000 Subject: Utilisateur : Fcolin Date : 2/06/06 Heure : 16:47 Archivé dans $/CSharp/Ivy/Ivy Commentaire: Mise en conformite du code avec les guidelines , et changement prototype evenements (vss 6) --- CSharp/Ivy/Ivy/IvyUDPStreamV3.cs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/CSharp/Ivy/Ivy/IvyUDPStreamV3.cs b/CSharp/Ivy/Ivy/IvyUDPStreamV3.cs index 027789a..99fb87c 100644 --- a/CSharp/Ivy/Ivy/IvyUDPStreamV3.cs +++ b/CSharp/Ivy/Ivy/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(); } } -- cgit v1.1