/// <inheritdoc /> public void WriteDelta(Stream stream) { using (PooledBitWriter writer = PooledBitWriter.Get(stream)) { writer.WriteUInt16Packed((ushort)dirtyEvents.Count); for (int i = 0; i < dirtyEvents.Count; i++) { writer.WriteBits((byte)dirtyEvents[i].eventType, 2); switch (dirtyEvents[i].eventType) { case NetworkedSetEvent <T> .EventType.Add: { writer.WriteObjectPacked(dirtyEvents[i].value); //BOX } break; case NetworkedSetEvent <T> .EventType.Remove: { writer.WriteObjectPacked(dirtyEvents[i].value); //BOX } break; case NetworkedSetEvent <T> .EventType.Clear: { //Nothing has to be written } break; } } } }
/// <inheritdoc /> public void WriteDelta(Stream stream) { using (PooledBitWriter writer = PooledBitWriter.Get(stream)) { writer.WriteUInt16Packed((ushort)dirtyEvents.Count); for (int i = 0; i < dirtyEvents.Count; i++) { writer.WriteBits((byte)dirtyEvents[i].eventType, 3); switch (dirtyEvents[i].eventType) { //F**k me these signatures are proper aids case NetworkedListEvent <T> .EventType.Add: { writer.WriteObjectPacked(dirtyEvents[i].value); //BOX } break; case NetworkedListEvent <T> .EventType.Insert: { writer.WriteInt32Packed(dirtyEvents[i].index); writer.WriteObjectPacked(dirtyEvents[i].value); //BOX } break; case NetworkedListEvent <T> .EventType.Remove: { writer.WriteObjectPacked(dirtyEvents[i].value); //BOX } break; case NetworkedListEvent <T> .EventType.RemoveAt: { writer.WriteInt32Packed(dirtyEvents[i].index); } break; case NetworkedListEvent <T> .EventType.Value: { writer.WriteInt32Packed(dirtyEvents[i].index); writer.WriteObjectPacked(dirtyEvents[i].value); //BOX } break; case NetworkedListEvent <T> .EventType.Clear: { //Nothing has to be written } break; } } } }
/// <inheritdoc /> public void WriteField(Stream stream) { using (PooledBitWriter writer = PooledBitWriter.Get(stream)) { writer.WriteUInt16Packed((ushort)dictionary.Count); foreach (KeyValuePair <TKey, TValue> pair in dictionary) { writer.WriteObjectPacked(pair.Key); writer.WriteObjectPacked(pair.Value); } } }
public void WriteDelta(Stream stream) => WriteField(stream); // Based on default NetworkedVar implementation. This class doesnt need this /// <inheritdoc /> public void WriteField(Stream stream) { using (PooledBitWriter writer = PooledBitWriter.Get(stream)) { writer.WriteObjectPacked(InternalValue); //BOX } }
internal static void HandleClientRPCRequest(ulong clientId, Stream stream, string channelName, SecuritySendFlags security) { using (PooledBitReader reader = PooledBitReader.Get(stream)) { ulong networkId = reader.ReadUInt64Packed(); ushort behaviourId = reader.ReadUInt16Packed(); ulong hash = reader.ReadUInt64Packed(); ulong responseId = reader.ReadUInt64Packed(); if (SpawnManager.SpawnedObjects.ContainsKey(networkId)) { NetworkedBehaviour behaviour = SpawnManager.SpawnedObjects[networkId].GetBehaviourAtOrderIndex(behaviourId); if (behaviour != null) { object result = behaviour.OnRemoteClientRPC(hash, clientId, stream); using (PooledBitStream responseStream = PooledBitStream.Get()) { using (PooledBitWriter responseWriter = PooledBitWriter.Get(responseStream)) { responseWriter.WriteUInt64Packed(responseId); responseWriter.WriteObjectPacked(result); } InternalMessageSender.Send(clientId, MLAPIConstants.MLAPI_CLIENT_RPC_RESPONSE, channelName, responseStream, security, null); } } } } }
/// <inheritdoc /> public void WriteField(Stream stream) { using (PooledBitWriter writer = PooledBitWriter.Get(stream)) { writer.WriteUInt16Packed((ushort)list.Count); for (int i = 0; i < list.Count; i++) { writer.WriteObjectPacked(list[i]); //BOX } } }
internal static void HandleClientRPCRequest(ulong clientId, Stream stream, string channelName, SecuritySendFlags security, Action <ulong> bufferCallback) { using (PooledBitReader reader = PooledBitReader.Get(stream)) { ulong networkId = reader.ReadUInt64Packed(); ushort behaviourId = reader.ReadUInt16Packed(); ulong hash = reader.ReadUInt64Packed(); ulong responseId = reader.ReadUInt64Packed(); if (SpawnManager.SpawnedObjects.ContainsKey(networkId)) { NetworkedBehaviour behaviour = SpawnManager.SpawnedObjects[networkId].GetBehaviourAtOrderIndex(behaviourId); if (behaviour == null) { if (LogHelper.CurrentLogLevel <= LogLevel.Normal) { LogHelper.LogWarning("ClientRPCRequest message recieved for a non existant behaviour. NetworkId: " + networkId + ", behaviourIndex: " + behaviourId); } } else { object result = behaviour.OnRemoteClientRPC(hash, clientId, stream); using (PooledBitStream responseStream = PooledBitStream.Get()) { using (PooledBitWriter responseWriter = PooledBitWriter.Get(responseStream)) { responseWriter.WriteUInt64Packed(responseId); responseWriter.WriteObjectPacked(result); } InternalMessageSender.Send(clientId, MLAPIConstants.MLAPI_CLIENT_RPC_RESPONSE, channelName, responseStream, security, null); } } } else if (NetworkingManager.Singleton.IsServer || !NetworkingManager.Singleton.NetworkConfig.EnableMessageBuffering) { if (LogHelper.CurrentLogLevel <= LogLevel.Normal) { LogHelper.LogWarning("ClientRPCRequest message recieved for a non existant object with id: " + networkId + ". This message is lost."); } } else { if (LogHelper.CurrentLogLevel <= LogLevel.Normal) { LogHelper.LogWarning("ClientRPCRequest message recieved for a non existant object with id: " + networkId + ". This message will be buffered and might be recovered."); } bufferCallback(networkId); } } }
/// <inheritdoc /> public void WriteField(Stream stream) { using (PooledBitWriter writer = PooledBitWriter.Get(stream)) { writer.WriteUInt16Packed((ushort)set.Count); foreach (T value in set) { writer.WriteObjectPacked(value); //BOX } } }
internal void WriteValue(Stream stream, bool checkDirty = true) { using (PooledBitWriter writer = PooledBitWriter.Get(stream)) { if (checkDirty) { // Trigger a value update IsDirty(); } writer.WriteObjectPacked(value); } }
internal void SendClientRPCBoxed(uint clientIdToIgnore, ulong hash, string channel, SecuritySendFlags security, params object[] parameters) { using (PooledBitStream stream = PooledBitStream.Get()) { using (PooledBitWriter writer = PooledBitWriter.Get(stream)) { for (int i = 0; i < parameters.Length; i++) { writer.WriteObjectPacked(parameters[i]); } SendClientRPCPerformance(hash, stream, clientIdToIgnore, channel, security); } } }
/// <inheritdoc /> public void WriteDelta(Stream stream) { using (PooledBitWriter writer = PooledBitWriter.Get(stream)) { writer.WriteUInt16Packed((ushort)dirtyEvents.Count); for (int i = 0; i < dirtyEvents.Count; i++) { writer.WriteBits((byte)dirtyEvents[i].eventType, 3); switch (dirtyEvents[i].eventType) { case NetworkedDictionaryEvent <TKey, TValue> .NetworkedListEventType.Add: { writer.WriteObjectPacked(dirtyEvents[i].key); writer.WriteObjectPacked(dirtyEvents[i].value); } break; case NetworkedDictionaryEvent <TKey, TValue> .NetworkedListEventType.Remove: { writer.WriteObjectPacked(dirtyEvents[i].key); } break; case NetworkedDictionaryEvent <TKey, TValue> .NetworkedListEventType.RemovePair: { writer.WriteObjectPacked(dirtyEvents[i].key); writer.WriteObjectPacked(dirtyEvents[i].value); } break; case NetworkedDictionaryEvent <TKey, TValue> .NetworkedListEventType.Clear: { //write nothing } break; case NetworkedDictionaryEvent <TKey, TValue> .NetworkedListEventType.Value: { writer.WriteObjectPacked(dirtyEvents[i].key); writer.WriteObjectPacked(dirtyEvents[i].value); } break; default: break; } } } }
internal static void HandleServerRPCRequest(ulong clientId, Stream stream, string channelName, SecuritySendFlags security) { using (PooledBitReader reader = PooledBitReader.Get(stream)) { ulong networkId = reader.ReadUInt64Packed(); ushort behaviourId = reader.ReadUInt16Packed(); ulong hash = reader.ReadUInt64Packed(); ulong responseId = reader.ReadUInt64Packed(); if (SpawnManager.SpawnedObjects.ContainsKey(networkId)) { NetworkedBehaviour behaviour = SpawnManager.SpawnedObjects[networkId].GetBehaviourAtOrderIndex(behaviourId); if (behaviour == null) { if (LogHelper.CurrentLogLevel <= LogLevel.Normal) { LogHelper.LogWarning("ServerRPCRequest message recieved for a non existant behaviour. NetworkId: " + networkId + ", behaviourIndex: " + behaviourId); } } else { object result = behaviour.OnRemoteServerRPC(hash, clientId, stream); using (PooledBitStream responseStream = PooledBitStream.Get()) { using (PooledBitWriter responseWriter = PooledBitWriter.Get(responseStream)) { responseWriter.WriteUInt64Packed(responseId); responseWriter.WriteObjectPacked(result); } InternalMessageSender.Send(clientId, MLAPIConstants.MLAPI_SERVER_RPC_RESPONSE, channelName, responseStream, security, SpawnManager.SpawnedObjects[networkId]); } } } else { if (LogHelper.CurrentLogLevel <= LogLevel.Normal) { LogHelper.LogWarning("ServerRPCRequest message recieved for a non existant object with id: " + networkId + ". This message is lost."); } } } }