public object Deserialize(Stream inStream) { TriggerObjectEventMessage msg = (TriggerObjectEventMessage)_serialize.Deserialize(inStream); var rc = TriggerObjectEventMessageConverter.FromProtoBuf(msg); msg.ReleaseReference(); return(rc); }
public void Serialize(Stream outStream, object message) { var syncEvent = (TriggerObjectSyncEvent)message; var msg = TriggerObjectEventMessage.Allocate(); TriggerObjectEventMessageConverter.ToProtoBuf(msg, syncEvent); _serialize.Serialize(outStream, msg); msg.ReleaseReference(); }
public static void ToProtoBuf(TriggerObjectEventMessage msg, TriggerObjectSyncEvent syncEvent) { switch (syncEvent.EType) { case TriggerObjectSyncEventType.DetachChunk: case TriggerObjectSyncEventType.BreakChunk: { msg.EventType = (int)syncEvent.EType; msg.SourceId = syncEvent.SourceObjectId; var detachChunkEvent = (ChunkSyncEvent)syncEvent; msg.Ints.Add(detachChunkEvent.ChunkId); break; } default: throw new Exception("Unkown TriggerObjectSyncEvent Type : " + syncEvent.EType); } }
public static TriggerObjectSyncEvent FromProtoBuf(TriggerObjectEventMessage message) { switch (message.EventType) { case (int)TriggerObjectSyncEventType.DetachChunk: case (int)TriggerObjectSyncEventType.BreakChunk: { var detachChunkEvent = ChunkSyncEvent.Allocate(); detachChunkEvent.EType = (TriggerObjectSyncEventType)message.EventType; detachChunkEvent.SourceObjectId = message.SourceId; detachChunkEvent.ChunkId = message.Ints[0]; return(detachChunkEvent); } default: throw new Exception("Unkown TriggerObjectSyncEventType : " + message.EventType); } }