public override uint FromBytes(Binary serializer, Binary.Buffer buffer, uint start) { uint read = 0; byte[] raw_guid; byte channel_type; ushort heartbeat_ticks; read += serializer.FromBytes(buffer, start + read, out raw_guid); read += serializer.FromBytes(buffer, start + read, out channel); read += serializer.FromBytes(buffer, start + read, out channel_type); read += serializer.FromBytes(buffer, start + read, out heartbeat_ticks); read += serializer.FromBytes(buffer, start + read, out autoReconnect); guid = new Guid(raw_guid); type = (Net.Negotiation.Channel.Type)channel_type; if (heartbeat_ticks == ushort.MaxValue) { heartbeat = new TimeSpan(0, 0, 0, 0, -1); } else { heartbeat = new TimeSpan(heartbeat_ticks * 100 * TimeSpan.TicksPerMillisecond); } return(read); }
public uint FromBytes(Binary serializer, Binary.Buffer buffer, uint start) { string raw_type; uint read = serializer.FromBytes(buffer, start, out raw_type); type = System.Type.GetType(raw_type); read += serializer.FromBytes(buffer, start + read, out resolved); if (resolved) { read += serializer.FromBytes(buffer, start + read, out id); read += serializer.FromBytes(buffer, start + read, out part); } else { int instance_id; // This deserialization should never be used in normal case. Serialization of unresolved reference // is only usefull to compute the unique hash of each node to group them together. Deserialization // is not needed for this process. read += serializer.FromBytes(buffer, start + read, out instance_id); } return(read); }
public bool Receive(out Message.Base message) { uint read = 0; uint size = 0; message = null; if (stream != null && parent != null) { if (ReceiveData(stream, headerBuffer, headerSize)) { message = Pattern.Factory <Message.Base, byte> .CreateInstance(headerBuffer[0]); size = new Converter32(headerBuffer[1], headerBuffer[2], headerBuffer[3], headerBuffer[4]); Binary.Buffer buffer = parent.Serializer.GetBuffer(size); if (ReceiveData(stream, buffer.Data, size)) { read = parent.Serializer.FromBytesOverwrite(buffer, 0, message); } } } return(message != null && read == size); }
public void ToUnity(Scene scene, Component component, System.Type type) { using (Binary.Buffer buffer = Module.Import.Binary.serializer.GetBufferFromExistingData(serialized)) { Module.Import.Binary.serializer.FromBytesOverwrite(buffer, 0, component as IBinarySerializable); } }
private string ComputeHash(Scene scene, Transform trans) { Binary.Buffer buffer = Module.Import.Binary.serializer.GetBuffer(5 * 1024); // Start with 5 Ko buffer uint written = 0; foreach (Component component in trans.GetComponents <Component>()) { if (SerializedComponent(component)) { written += Module.Import.Binary.serializer.ToBytes(ref buffer, written, UnityComponent.FromUnity(scene, component)); } } uint size = (uint)System.Text.Encoding.UTF8.GetByteCount(name); size += 2 * Binary.Size(Binary.SupportedTypes.UNITY_VECTOR3); size += Binary.Size(Binary.SupportedTypes.UNITY_QUATERNION); Module.Import.Binary.serializer.ResizeBuffer(ref buffer, written + size); written += Module.Import.Binary.serializer.ToBytes(ref buffer, written, trans.name); written += Module.Import.Binary.serializer.ToBytes(ref buffer, written, trans.localPosition); written += Module.Import.Binary.serializer.ToBytes(ref buffer, written, trans.localRotation); written += Module.Import.Binary.serializer.ToBytes(ref buffer, written, trans.localScale); return(Hash.ComputeHash(buffer.Data, 0, (int)written)); }
public void FromUnity(Scene scene, Component component, System.Type type) { // We can not use the 'Serialize' high level method directly as deserialization will require // the use of explicit low level 'FromBytesOverwrite'. Therefore, we must do things manually here. Binary serializer = Module.Import.Binary.serializer; Binary.Buffer buffer = null; try { buffer = serializer.GetBuffer(Binary.defaultSerializationBufferSize); uint written = serializer.ToBytes(ref buffer, 0, component as IBinarySerializable); serialized = new byte[written]; Array.Copy(buffer.Data, serialized, written); } catch (Exception e) { throw new Binary.SerializationException("An error occured during serialization.", e); } finally { if (buffer != null) { buffer.Dispose(); } } }
public uint DeserializationCallback(Binary serializer, Binary.Buffer buffer) { uint read = serializer.FromBytes(buffer, 0, out object d); data = d as IBinarySerializable; return(read); }
public override uint FromBytes(Binary serializer, Binary.Buffer buffer, uint start) { uint read = 0; read += serializer.FromBytes(buffer, start + read, out accepted); return(read); }
public uint ToBytes(Binary serializer, ref Binary.Buffer buffer, uint start) { uint written = serializer.ToBytes(ref buffer, start, (int)topology); written += serializer.ToBytes(ref buffer, start + written, triangles); return(written); }
public uint FromBytes(Binary serializer, Binary.Buffer buffer, uint start) { uint read = serializer.FromBytes(buffer, start, out meshIndex); read += serializer.FromBytes(buffer, start + read, out materialsIndexes); return(read); }
public uint ToBytes(Binary serializer, ref Binary.Buffer buffer, uint start) { uint written = serializer.ToBytes(ref buffer, start, meshIndex); written += serializer.ToBytes(ref buffer, start + written, materialsIndexes); return(written); }
public uint ToBytes(Binary serializer, ref Binary.Buffer buffer, uint start) { uint written = serializer.ToBytes(ref buffer, start, index); written += serializer.ToBytes(ref buffer, start + written, offset); written += serializer.ToBytes(ref buffer, start + written, scale); return(written); }
/// <summary> /// Save all the recorded commands to a file. /// Should be called after Stop() and before next Wait(). /// </summary> /// <param name="filename">file path</param> public void Save(string filename) { Binary.Buffer buffer = serializer.Serialize(commands); using (FileStream stream = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None)) { stream.Write(buffer.Data, 0, (int)buffer.Size); } }
public uint FromBytes(Binary serializer, Binary.Buffer buffer, uint start) { uint read = 0; read += serializer.FromBytes(buffer, start + read, out fields); read += serializer.FromBytes(buffer, start + read, out properties); return(read); }
public uint Callback(Binary serializer, ref Binary.Buffer buffer) { uint written = 0; written += serializer.ToBytes(ref buffer, written, Type); written += serializer.ToBytes(ref buffer, written, Data); return(written); }
public uint FromBytes(Binary serializer, Binary.Buffer buffer, uint start) { uint read = serializer.FromBytes(buffer, start, out index); read += serializer.FromBytes(buffer, start + read, out offset); read += serializer.FromBytes(buffer, start + read, out scale); return(read); }
public uint ToBytes(Binary serializer, ref Binary.Buffer buffer, uint start) { uint written = 0; written += serializer.ToBytes(ref buffer, start + written, fields); written += serializer.ToBytes(ref buffer, start + written, properties); return(written); }
public uint ToBytes(Binary serializer, ref Binary.Buffer buffer, uint start) { uint written = 0; written += serializer.ToBytes(ref buffer, start + written, type); written += backend.ToBytes(serializer, ref buffer, start + written); return(written); }
public uint ToBytes(Binary serializer, ref Binary.Buffer buffer, uint start) { uint written = serializer.ToBytes(ref buffer, start, root_node); written += serializer.ToBytes(ref buffer, start + written, meshes); written += serializer.ToBytes(ref buffer, start + written, materials); written += serializer.ToBytes(ref buffer, start + written, textures); return(written); }
public override uint FromBytes(Binary serializer, Binary.Buffer buffer, uint start) { uint read = 0; read += serializer.FromBytes(buffer, start + read, out version); read += serializer.FromBytes(buffer, start + read, out username); read += serializer.FromBytes(buffer, start + read, out password); return(read); }
public uint FromBytes(Binary serializer, Binary.Buffer buffer, uint start) { uint read = 0; read += serializer.FromBytes(buffer, start + read, out active); read += BytesToInfo(serializer, buffer, start + read); return(read); }
public uint ToBytes(Binary serializer, ref Binary.Buffer buffer, uint start) { uint written = 0; written += serializer.ToBytes(ref buffer, start + written, active); written += InfoToBytes(serializer, ref buffer, start + written); return(written); }
public uint ToBytes(Binary serializer, ref Binary.Buffer buffer, uint start) { uint written = 0; written += serializer.ToBytes(ref buffer, start + written, timestamp); written += serializer.ToBytes(ref buffer, start + written, position); written += serializer.ToBytes(ref buffer, start + written, rotation); written += serializer.ToBytes(ref buffer, start + written, scale); return(written); }
public uint FromBytes(Binary serializer, Binary.Buffer buffer, uint start) { uint read = 0; read += serializer.FromBytes(buffer, start + read, out timestamp); read += serializer.FromBytes(buffer, start + read, out position); read += serializer.FromBytes(buffer, start + read, out rotation); read += serializer.FromBytes(buffer, start + read, out scale); return(read); }
public uint ToBytes(Binary serializer, ref Binary.Buffer buffer, uint start) { uint written = serializer.ToBytes(ref buffer, start, filename); written += serializer.ToBytes(ref buffer, start + written, width); written += serializer.ToBytes(ref buffer, start + written, height); written += serializer.ToBytes(ref buffer, start + written, (int)format); written += serializer.ToBytes(ref buffer, start + written, data); return(written); }
public uint ToBytes(Binary serializer, ref Binary.Buffer buffer, uint start) { uint written = 0; written += serializer.ToBytes(ref buffer, start + written, exist); written += serializer.ToBytes(ref buffer, start + written, port); written += serializer.ToBytes(ref buffer, start + written, info); written += serializer.ToBytes(ref buffer, start + written, ComputeControlSum(buffer.Data, start, written)); return(written); }
public uint FromBytes(Binary serializer, Binary.Buffer buffer, uint start) { int topo; uint read = serializer.FromBytes(buffer, start, out topo); read += serializer.FromBytes(buffer, start + read, out triangles); topology = (MeshTopology)topo; return(read); }
public uint FromBytes(Binary serializer, Binary.Buffer buffer, uint start) { uint read = 0; read += serializer.FromBytes(buffer, start + read, out type); CreateBackend(); read += backend.FromBytes(serializer, buffer, start + read); return(read); }
public override uint ToBytes(Binary serializer, ref Binary.Buffer buffer, uint start) { uint written = 0; const uint message_size = sizeof(bool); serializer.ResizeBuffer(ref buffer, start + message_size); written += serializer.ToBytes(ref buffer, start + written, accepted); return(written); }
public override uint ToBytes(Binary serializer, ref Binary.Buffer buffer, uint start) { uint written = 0; serializer.ResizeBuffer(ref buffer, start + messageSize); written += serializer.ToBytes(ref buffer, start + written, guid.ToByteArray()); written += serializer.ToBytes(ref buffer, start + written, channel); written += serializer.ToBytes(ref buffer, start + written, port); return(written); }