Skip to content

Commit

Permalink
Added checks to prevent sending on the MLAPI channels
Browse files Browse the repository at this point in the history
  • Loading branch information
TwoTenPvP committed Mar 4, 2018
1 parent 82d4498 commit 9c67396
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ private void OnDestroy()

protected void SendToServer(string messageType, string channelName, byte[] data)
{
if(MessageManager.messageTypes[messageType] < 32)
{
Debug.LogWarning("MLAPI: Sending messages on the internal MLAPI channels is not allowed!");
return;
}
if (isServer)
{
MessageManager.InvokeMessageHandlers(messageType, data, -1);
Expand All @@ -114,6 +119,11 @@ protected void SendToServer(string messageType, string channelName, byte[] data)

protected void SendToServerTarget(string messageType, string channelName, byte[] data)
{
if (MessageManager.messageTypes[messageType] < 32)
{
Debug.LogWarning("MLAPI: Sending messages on the internal MLAPI channels is not allowed!");
return;
}
if (isServer)
{
MessageManager.InvokeTargetedMessageHandler(messageType, data, -1, networkId);
Expand All @@ -126,6 +136,11 @@ protected void SendToServerTarget(string messageType, string channelName, byte[]

protected void SendToLocalClient(string messageType, string channelName, byte[] data)
{
if (MessageManager.messageTypes[messageType] < 32)
{
Debug.LogWarning("MLAPI: Sending messages on the internal MLAPI channels is not allowed!");
return;
}
if (!isServer && (!NetworkingManager.singleton.NetworkConfig.AllowPassthroughMessages || !NetworkingManager.singleton.NetworkConfig.PassthroughMessageTypes.Contains(messageType)))
{
Debug.LogWarning("MLAPI: Invalid Passthrough send. Ensure AllowPassthroughMessages are turned on and that the MessageType " + messageType + " is registered as a passthroughMessageType");
Expand All @@ -136,6 +151,11 @@ protected void SendToLocalClient(string messageType, string channelName, byte[]

protected void SendToLocalClientTarget(string messageType, string channelName, byte[] data)
{
if (MessageManager.messageTypes[messageType] < 32)
{
Debug.LogWarning("MLAPI: Sending messages on the internal MLAPI channels is not allowed!");
return;
}
if (!isServer && (!NetworkingManager.singleton.NetworkConfig.AllowPassthroughMessages || !NetworkingManager.singleton.NetworkConfig.PassthroughMessageTypes.Contains(messageType)))
{
Debug.LogWarning("MLAPI: Invalid Passthrough send. Ensure AllowPassthroughMessages are turned on and that the MessageType " + messageType + " is registered as a passthroughMessageType");
Expand All @@ -146,6 +166,11 @@ protected void SendToLocalClientTarget(string messageType, string channelName, b

protected void SendToNonLocalClients(string messageType, string channelName, byte[] data)
{
if (MessageManager.messageTypes[messageType] < 32)
{
Debug.LogWarning("MLAPI: Sending messages on the internal MLAPI channels is not allowed!");
return;
}
if (!isServer)
{
Debug.LogWarning("MLAPI: Sending messages from client to other clients is not yet supported");
Expand All @@ -156,6 +181,11 @@ protected void SendToNonLocalClients(string messageType, string channelName, byt

protected void SendToNonLocalClientsTarget(string messageType, string channelName, byte[] data)
{
if (MessageManager.messageTypes[messageType] < 32)
{
Debug.LogWarning("MLAPI: Sending messages on the internal MLAPI channels is not allowed!");
return;
}
if (!isServer)
{
Debug.LogWarning("MLAPI: Sending messages from client to other clients is not yet supported");
Expand All @@ -166,6 +196,11 @@ protected void SendToNonLocalClientsTarget(string messageType, string channelNam

protected void SendToClient(int clientId, string messageType, string channelName, byte[] data)
{
if (MessageManager.messageTypes[messageType] < 32)
{
Debug.LogWarning("MLAPI: Sending messages on the internal MLAPI channels is not allowed!");
return;
}
if (!isServer && (!NetworkingManager.singleton.NetworkConfig.AllowPassthroughMessages || !NetworkingManager.singleton.NetworkConfig.PassthroughMessageTypes.Contains(messageType)))
{
Debug.LogWarning("MLAPI: Invalid Passthrough send. Ensure AllowPassthroughMessages are turned on and that the MessageType " + messageType + " is registered as a passthroughMessageType");
Expand All @@ -176,6 +211,11 @@ protected void SendToClient(int clientId, string messageType, string channelName

protected void SendToClientTarget(int clientId, string messageType, string channelName, byte[] data)
{
if (MessageManager.messageTypes[messageType] < 32)
{
Debug.LogWarning("MLAPI: Sending messages on the internal MLAPI channels is not allowed!");
return;
}
if (!isServer && (!NetworkingManager.singleton.NetworkConfig.AllowPassthroughMessages || !NetworkingManager.singleton.NetworkConfig.PassthroughMessageTypes.Contains(messageType)))
{
Debug.LogWarning("MLAPI: Invalid Passthrough send. Ensure AllowPassthroughMessages are turned on and that the MessageType " + messageType + " is registered as a passthroughMessageType");
Expand All @@ -186,6 +226,11 @@ protected void SendToClientTarget(int clientId, string messageType, string chann

protected void SendToClients(int[] clientIds, string messageType, string channelName, byte[] data)
{
if (MessageManager.messageTypes[messageType] < 32)
{
Debug.LogWarning("MLAPI: Sending messages on the internal MLAPI channels is not allowed!");
return;
}
if (!isServer)
{
Debug.LogWarning("MLAPI: Sending messages from client to other clients is not yet supported");
Expand All @@ -196,6 +241,11 @@ protected void SendToClients(int[] clientIds, string messageType, string channel

protected void SendToClientsTarget(int[] clientIds, string messageType, string channelName, byte[] data)
{
if (MessageManager.messageTypes[messageType] < 32)
{
Debug.LogWarning("MLAPI: Sending messages on the internal MLAPI channels is not allowed!");
return;
}
if (!isServer)
{
Debug.LogWarning("MLAPI: Sending messages from client to other clients is not yet supported");
Expand All @@ -206,6 +256,11 @@ protected void SendToClientsTarget(int[] clientIds, string messageType, string c

protected void SendToClients(List<int> clientIds, string messageType, string channelName, byte[] data)
{
if (MessageManager.messageTypes[messageType] < 32)
{
Debug.LogWarning("MLAPI: Sending messages on the internal MLAPI channels is not allowed!");
return;
}
if (!isServer)
{
Debug.LogWarning("MLAPI: Sending messages from client to other clients is not yet supported");
Expand All @@ -216,6 +271,11 @@ protected void SendToClients(List<int> clientIds, string messageType, string cha

protected void SendToClientsTarget(List<int> clientIds, string messageType, string channelName, byte[] data)
{
if (MessageManager.messageTypes[messageType] < 32)
{
Debug.LogWarning("MLAPI: Sending messages on the internal MLAPI channels is not allowed!");
return;
}
if (!isServer)
{
Debug.LogWarning("MLAPI: Sending messages from client to other clients is not yet supported");
Expand All @@ -226,6 +286,11 @@ protected void SendToClientsTarget(List<int> clientIds, string messageType, stri

protected void SendToClients(string messageType, string channelName, byte[] data)
{
if (MessageManager.messageTypes[messageType] < 32)
{
Debug.LogWarning("MLAPI: Sending messages on the internal MLAPI channels is not allowed!");
return;
}
if (!isServer)
{
Debug.LogWarning("MLAPI: Sending messages from client to other clients is not yet supported");
Expand All @@ -236,6 +301,11 @@ protected void SendToClients(string messageType, string channelName, byte[] data

protected void SendToClientsTarget(string messageType, string channelName, byte[] data)
{
if (MessageManager.messageTypes[messageType] < 32)
{
Debug.LogWarning("MLAPI: Sending messages on the internal MLAPI channels is not allowed!");
return;
}
if (!isServer)
{
Debug.LogWarning("MLAPI: Sending messages from client to other clients is not yet supported");
Expand Down

0 comments on commit 9c67396

Please sign in to comment.