/// <summary> /// Writes <see cref="IComponentBroadcaster"/> information to a network message for sending to other devices /// </summary> /// <param name="message">network message to send</param> /// <param name="component">component that has changed</param> /// <param name="changeType">type of changed that occurred for the specified component</param> public void WriteHeader(BinaryWriter message, IComponentBroadcaster component, ComponentBroadcasterChangeType changeType = ComponentBroadcasterChangeType.Updated) { StateSynchronizationSceneManager.Instance.WriteSynchronizeCommandHeader(message); message.Write(GetID().Value); message.Write(component.TransformBroadcaster.Id); message.Write((byte)changeType); }
private static bool IsComponentDestroyed(IComponentBroadcaster component) { // We need the MonoBehaviour override of the == operator in order to determine // if the component is destroyed, since destroyed components are non-null in the // CLR sense. MonoBehaviour behavior = (MonoBehaviour)component; return(behavior == null); }
private void SendComponentDestruction(IEnumerable <SocketEndpoint> endpoints, IComponentBroadcaster component) { using (MemoryStream memoryStream = new MemoryStream()) using (BinaryWriter message = new BinaryWriter(memoryStream)) { component.ComponentBroadcasterService.WriteHeader(message, component, ComponentBroadcasterChangeType.Destroyed); message.Flush(); Send(endpoints, memoryStream.ToArray()); } }
internal void AddComponentBroadcaster(IComponentBroadcaster ComponentBroadcaster) { broadcasterComponents.Add(ComponentBroadcaster); }
private void SendComponentDestruction(IEnumerable <INetworkConnection> connections, IComponentBroadcaster component) { using (MemoryStream memoryStream = new MemoryStream()) using (BinaryWriter message = new BinaryWriter(memoryStream)) { component.ComponentBroadcasterService.WriteHeader(message, component, ComponentBroadcasterChangeType.Destroyed); message.Flush(); memoryStream.TryGetBuffer(out var buffer); Send(connections, buffer.Array, buffer.Offset, buffer.Count); } }
private void SendComponentDestruction(IEnumerable <INetworkConnection> connections, IComponentBroadcaster component) { using (MemoryStream memoryStream = new MemoryStream()) using (BinaryWriter message = new BinaryWriter(memoryStream)) { component.ComponentBroadcasterService.WriteHeader(message, component, ComponentBroadcasterChangeType.Destroyed); message.Flush(); Send(connections, memoryStream.GetBuffer(), 0, memoryStream.Position); } }