alvyxaz / barebones-masterserver

Master Server framework for Unity
475 stars 106 forks source link

How To Make Server Send Message to Clients When All Players are Ready (Lobby) ? #212

Open gotanidea opened 6 years ago

gotanidea commented 6 years ago

I want to notify all clients when all players in a lobby are ready. I added this code in BaseLobby.cs - OnAllPlayersReady() function:

IServerSocket server = new ServerSocketUnet();

server.Connected += peer =>
{
     peer.SendMessage(0, "What's up?");
};

And this code in ConnectionToMaster.cs - Start() function:

IClientSocket client = new ClientSocketUnet();

client.Connected += () =>
{
     client.Peer.MessageReceived += message =>
     {
          Debug.Log("I've got the message!: " + message.AsString());
     };
};

But I don't get any message on the client. How to make the server send message to the clients when all players in the lobby are ready?