Question by
oomeroo1999 · Jun 26, 2019 at 10:10 AM ·
multiplayermultiplayer-networkingbroadcastmessagebroadcast
Multiplayer - Using BroadCast in OnIncomingData function
Client code:
Debug.Log("Client : " + data);
string[] aData = data.Split('|');
switch (aData[0])
{
case "SWHO":
Send("CWHO|" + clientName);
break;
Server code:
Debug.Log("Server : " + data);
string[] aData = data.Split('|');
switch (aData[0])
{
case "CWHO":
c.clientName = aData[1];
BroadCast("SCNN|" + c.clientName, clients);
Debug.Log("I AM: " + clients[clients.Count - 1].clientName);
BroadCast("SNUM|" + c.clientName, clients[clients.Count - 1]);
break;
I don't build the project, I only sign as host.
The output is:
Client: SWHO|
Server: CWHO|Host
I AM: HOST
Client: SCNN|Host
What I expected is:
Client: SWHO|
Server: CWHO|Host
Client: SCNN|Host
I AM: HOST
Client: SNUM|Host
Why "SNUM|" doesn't come up ? I send the message to the last connected client so that's the host !?
Edit: If I write "BroadCast("SNUM|")" before "BroadCast("SCNN")" , "SNUM" comes up but "SCNN" doesn't come up.
Can't I call BroadCast two times ? ?
Comment
Best Answer
Answer by oomeroo1999 · Jun 28, 2019 at 09:42 AM
I solved it seperating broadcasts. Used SNUM in another case.