@@ -670,10 +670,7 @@ internal void PassthroughSend(int targetId, int sourceId, ushort messageType, in
670670 if ( isHost && targetId == - 1 )
671671 {
672672 //Host trying to send data to it's own client
673- if ( networkId == null )
674- MessageManager . InvokeMessageHandlers ( MessageManager . reverseMessageTypes [ messageType ] , data , sourceId ) ;
675- else
676- MessageManager . InvokeTargetedMessageHandler ( MessageManager . reverseMessageTypes [ messageType ] , data , sourceId , networkId . Value ) ;
673+ Debug . LogWarning ( "MLAPI: Send method got message aimed at server from the server?" ) ;
677674 return ;
678675 }
679676
@@ -701,13 +698,10 @@ internal void PassthroughSend(int targetId, int sourceId, ushort messageType, in
701698
702699 internal void Send ( int clientId , string messageType , string channelName , byte [ ] data , uint ? networkId = null )
703700 {
704- if ( isHost && clientId == - 1 )
701+ if ( clientId == - 1 && isHost )
705702 {
706- //Host trying to send data to it's own client
707- if ( networkId == null )
708- MessageManager . InvokeMessageHandlers ( messageType , data , clientId ) ;
709- else
710- MessageManager . InvokeTargetedMessageHandler ( messageType , data , clientId , networkId . Value ) ;
703+ //Don't invoke the message on our own machine. Instant stack overflow.
704+ Debug . LogWarning ( "MLAPI: Cannot send message to own client" ) ;
711705 return ;
712706 }
713707 else if ( clientId == - 1 )
@@ -775,10 +769,7 @@ internal void Send(int[] clientIds, string messageType, string channelName, byte
775769 int clientId = clientIds [ i ] ;
776770 if ( isHost && clientId == - 1 )
777771 {
778- if ( networkId == null )
779- MessageManager . InvokeMessageHandlers ( messageType , data , clientId ) ;
780- else
781- MessageManager . InvokeTargetedMessageHandler ( messageType , data , clientId , networkId . Value ) ;
772+ //Don't invoke the message on our own machine. Instant stack overflow.
782773 continue ;
783774 }
784775 else if ( clientId == - 1 )
@@ -815,12 +806,9 @@ internal void Send(List<int> clientIds, string messageType, string channelName,
815806 for ( int i = 0 ; i < clientIds . Count ; i ++ )
816807 {
817808 int clientId = clientIds [ i ] ;
818- if ( isHost && clientId == - 1 )
809+ if ( clientId == - 1 && isHost )
819810 {
820- if ( networkId == null )
821- MessageManager . InvokeMessageHandlers ( messageType , data , clientId ) ;
822- else
823- MessageManager . InvokeTargetedMessageHandler ( messageType , data , clientId , networkId . Value ) ;
811+ //Don't invoke the message on our own machine. Instant stack overflow.
824812 continue ;
825813 }
826814 else if ( clientId == - 1 )
@@ -859,10 +847,7 @@ internal void Send(string messageType, string channelName, byte[] data, uint? ne
859847 int clientId = pair . Key ;
860848 if ( isHost && pair . Key == - 1 )
861849 {
862- if ( networkId == null )
863- MessageManager . InvokeMessageHandlers ( messageType , data , clientId ) ;
864- else
865- MessageManager . InvokeTargetedMessageHandler ( messageType , data , clientId , networkId . Value ) ;
850+ //Don't invoke the message on our own machine. Instant stack overflow.
866851 continue ;
867852 }
868853 else if ( clientId == - 1 )
@@ -876,7 +861,7 @@ internal void Send(string messageType, string channelName, byte[] data, uint? ne
876861 }
877862 }
878863
879- internal void Send ( string messageType , string channelName , byte [ ] data , int clientIdToIgnore , uint ? networkId = null , bool ignoreHost = false )
864+ internal void Send ( string messageType , string channelName , byte [ ] data , int clientIdToIgnore , uint ? networkId = null )
880865 {
881866 //2 bytes for messageType, 2 bytes for buffer length and one byte for target bool
882867 int sizeOfStream = 5 ;
@@ -902,12 +887,9 @@ internal void Send(string messageType, string channelName, byte[] data, int clie
902887 if ( pair . Key == clientIdToIgnore )
903888 continue ;
904889 int clientId = pair . Key ;
905- if ( isHost && pair . Key == - 1 && ! ignoreHost )
890+ if ( isHost && pair . Key == - 1 )
906891 {
907- if ( networkId == null )
908- MessageManager . InvokeMessageHandlers ( messageType , data , clientId ) ;
909- else
910- MessageManager . InvokeTargetedMessageHandler ( messageType , data , clientId , networkId . Value ) ;
892+ //Don't invoke the message on our own machine. Instant stack overflow.
911893 continue ;
912894 }
913895 else if ( clientId == - 1 )
0 commit comments