Permalink
Browse files

Sync now uses raw bytes for time messages to avoid localization probl…

…ems. probably fixes #313
  • Loading branch information...
1 parent 1787831 commit d3b467fded695b9613da775a8fc40d99747993c9 @tebjan tebjan committed Feb 10, 2014
Showing with 22 additions and 17 deletions.
  1. +22 −17 vvvv45/src/nodes/plugins/Network/Sync.cs
@@ -1,17 +1,18 @@
#region usings
-using System;
-using System.ComponentModel.Composition;
-using System.Net;
-using System.Text;
-using System.Timers;
-
-using VVVV.Core.Logging;
-using VVVV.PluginInterfaces.V1;
-using VVVV.PluginInterfaces.V2;
-using VVVV.Utils.Animation;
-using VVVV.Utils.Network;
-using VVVV.Utils.VColor;
-using VVVV.Utils.VMath;
+using System;
+using System.ComponentModel.Composition;
+using System.IO;
+using System.Net;
+using System.Text;
+using System.Timers;
+
+using VVVV.Core.Logging;
+using VVVV.PluginInterfaces.V1;
+using VVVV.PluginInterfaces.V2;
+using VVVV.Utils.Animation;
+using VVVV.Utils.Network;
+using VVVV.Utils.VColor;
+using VVVV.Utils.VMath;
#endregion usings
@@ -150,7 +151,12 @@ void FServer_MessageReceived(object sender, UDPReceivedEventArgs e)
{
lock(FLock)
{
- FServer.Send(Encoding.ASCII.GetBytes(FStreamTime.ToString() + ";" + FTimeStamp.ToString()), e.RemoteSender);
+ using(var stream = new MemoryStream())
+ {
+ stream.Write(BitConverter.GetBytes(FStreamTime), 0, 8);
+ stream.Write(BitConverter.GetBytes(FTimeStamp), 0, 8);
+ FServer.Send(stream.ToArray(), e.RemoteSender);
+ }
//FLogger.Log(LogType.Debug, FStreamTime.ToString() + ";" + FHost.RealTime.ToString());
}
@@ -160,12 +166,11 @@ void FServer_MessageReceived(object sender, UDPReceivedEventArgs e)
void ReceiveServerAnswer(byte[] data)
{
FHalfRoundTripDelay = (FHost.RealTime - FRequestSentTimeStamp) * 0.5;
- var s = Encoding.ASCII.GetString(data).Split(';');
lock(FLock)
{
- FReceivedStreamTime = Double.Parse(s[0]);
- FReceivedTimeStamp = Double.Parse(s[1]);
+ FReceivedStreamTime = BitConverter.ToDouble(data, 0);
+ FReceivedTimeStamp = BitConverter.ToDouble(data, 8);
}
}

0 comments on commit d3b467f

Please sign in to comment.