summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfcolin2007-02-01 10:04:27 +0000
committerfcolin2007-02-01 10:04:27 +0000
commit60e715105d19a93bea7ff167bf81a35ea477a717 (patch)
tree0265604465de076cf59ae6249a62c65a78d5e2ee
parente9b7c3af5d6a104660e77d06a036514201753936 (diff)
downloadivy-csharp-60e715105d19a93bea7ff167bf81a35ea477a717.zip
ivy-csharp-60e715105d19a93bea7ff167bf81a35ea477a717.tar.gz
ivy-csharp-60e715105d19a93bea7ff167bf81a35ea477a717.tar.bz2
ivy-csharp-60e715105d19a93bea7ff167bf81a35ea477a717.tar.xz
Utilisateur : Fcolin Date : 30/11/05 Heure : 10:27 Créé Commentaire: (vss 1)
-rw-r--r--CSharp/Ivy/IvyPerf/IvyPerf.cs58
1 files changed, 58 insertions, 0 deletions
diff --git a/CSharp/Ivy/IvyPerf/IvyPerf.cs b/CSharp/Ivy/IvyPerf/IvyPerf.cs
new file mode 100644
index 0000000..2a23d22
--- /dev/null
+++ b/CSharp/Ivy/IvyPerf/IvyPerf.cs
@@ -0,0 +1,58 @@
+using System;
+using IvyBus;
+using System.Threading;
+using System.Globalization;
+
+namespace IvyPerf
+{
+ /// <summary>
+ /// Description résumée de Class1.
+ /// </summary>
+ class IvyPerf
+ {
+ static Ivy bus;
+ // manque d'homogeneitee format float en langue US
+ static CultureInfo c;
+
+ static double currentTime() // en ms
+ {
+ double time;
+ time = (double)DateTime.Now.Ticks / (double)TimeSpan.TicksPerMillisecond;
+ //time = Environment.TickCount;
+ return time;
+ }
+ static void Reply(IvyClient client, IvyArgument args)
+ {
+ bus.sendMsg(c,"pong ts={0} tr={1}", args, currentTime());
+ }
+ static void Pong(IvyClient client, IvyArgument args)
+ {
+ double current = currentTime();
+ double ts = double.Parse( args[0].Value, c );
+ double tr = double.Parse(args[1].Value, c);
+ double roundtrip1 = tr-ts;
+ double roundtrip2 = current - ts;
+ Console.WriteLine( "round trip {0} {1}", roundtrip1 , roundtrip2 );
+ }
+ /// <summary>
+ /// Point d'entrée principal de l'application.
+ /// </summary>
+ [STAThread]
+ static void Main(string[] args)
+ {
+ c = new CultureInfo("en-us");
+ bus = new Ivy("IvyPerf", "IvyPref ready");
+ bus.bindMsg( "^ping ts=(.*)", new Ivy.MessageHandler( Reply ) );
+ bus.bindMsg( "^pong ts=(.*) tr=(.*)", new Ivy.MessageHandler( Pong ) );
+ //bus.bindSimpleMsg( "ping:ts", new Ivy.MessageHandler( Reply ) );
+ //bus.bindSimpleMsg( "pong:ts,tr", new Ivy.MessageHandler( Pong ) );
+ bus.start(null);
+ while( true )
+ {
+ Thread.Sleep( 1000 );
+ int count = bus.sendMsg(c,"ping ts={0}", currentTime());
+ if ( count == 0 ) Console.Write( "." );
+ }
+ }
+ }
+}