public void OnDeseialize(byte[] data) { var d = Serilization.ByteArrayToObject <Datatex>(data); this.test = d.test; this.testString = d.testString; }
public static void DebugReport(GPUData data) { double now = Serilization.ConvertFrom2019(); double diff = now - data.serverTime; Debug.LogFormat("Server time is {0:0.000000}, with delta {1:0.000000}", data.serverTime, data.deltaTime); Debug.LogFormat("Client time is {0:0.000000}", now); Debug.LogFormat("Diff is {0:0.000000}", diff); }
static void Main(String[] args) { var items = new IITEM[] { new Book("Real-Time Rendering", 12.35, Currency.EUR, "1234556", "rudi"), new Book("The Hitchhiker's Guide to the Galaxy", 34.35, Currency.EUR, "56789", "olaf"), new Book("C# 6.0 in a Nutshell", 10.15, Currency.EUR, "78923", "zottl"), new Book("Trillions: Thriving in the Emerging Information Ecology", 67.45, Currency.EUR, "56748", "peter"), new Book("Cryptonomicon", 99.80, Currency.EUR, "98767", "Franz") }; Serilization.Run(items); }
// Update is called once per frame void Update() { //this.socket.Send(Time.deltaTime.ToString()); UDPServer.GPUData data; var now = Serilization.ConvertFrom2019(); //Debug.Log("Frame Start"); var deltaThisFrame = 0.0d; while (this.socket.deltaQueue.TryPeek(out data)) { var server = data.serverTime; var clientTarget = server + 5000; deltaThisFrame = clientTarget - now; //Debug.Log("deltaThisFrame" + deltaThisFrame); if (deltaThisFrame < 0) { if (this.socket.deltaQueue.TryDequeue(out data)) { //this.gameObject.transform.Rotate(Vector3.right * (data.deltaTime) * 20); var timeInSecond = (float)deltaThisFrame * 0.001f; var timeTick = data.deltaTime; this.gameObject.transform.localPosition = new Vector3( transform.localPosition.x, Mathf.Sin(sin += timeTick) * 5, transform.localPosition.z); currentDalta += timeInSecond + data.deltaTime; //Debug.Log("Tick" + deltaThisFrame); //Debug.Log("currentDalta" + currentDalta); } } else { break; } } if (currentDalta > 0 && false) { var tickTime = Mathf.Min(Time.deltaTime, (float)currentDalta); this.gameObject.transform.localPosition = new Vector3( transform.localPosition.x, Mathf.Sin(sin += tickTime) * 5, transform.localPosition.z); currentDalta -= tickTime; //Debug.Log("currentDalta Tick" + currentDalta); } }
IEnumerator Broadcast() { var socket = SocketData.Make("localhost", 12345); var socket1 = SocketData.Make("localhost", 12346); //socket.endPoint.Address = IPAddress.Broadcast; //this.socket.Setup(UDPSocket<GPUData>.SocketRole.Broadcast); var data = new GPUData(); while (true) { data.deltaTime = Time.deltaTime; data.serverTime = Serilization.ConvertFrom2019(); //this.socket.Send(socket, data); //this.socket.Send(socket1, data); this.socket.Broadcast(data, 12347); this.socket.Broadcast(data, 12348); yield return(new WaitForEndOfFrame()); } }
public override Data OnDeserialize(byte[] data, int length) { var remote = CompressTool.Decompress(data); return(Serilization.ByteArrayToObject <Data>(remote)); }
public override byte[] OnSerialize(Data data) { var raw = Serilization.ObjectToByteArray(data); return(CompressTool.Compress(raw)); }
public byte[] OnSerialize() { return(Serilization.ObjectToByteArray(this)); }
public virtual T OnDeserialize(byte[] data, int length) { //Note data may has different size than length return(Serilization.ByteArrayToObject <T>(data)); }
public virtual byte[] OnSerialize(T data) { return(Serilization.ObjectToByteArray(data)); }