I have seen in other librarys that they have a nice method that we can call Broadcast too, but with more one parameter, so can be a overload method for playerio, that send a message for all player but not for a specific player passed by parameter. Example:
The method can be:
- Code: Select all
public void Broadcast(int playerId, string type, params object[] parameters)
{
foreach (Player p in Players)
{
if (player.Id != playerId)
{
//send the message
}
}
}
and/or
- Code: Select all
public void Broadcast(int playerId, Message m)
{
foreach (Player p in Players)
{
if (player.Id != playerId)
{
//send the message
player.send(m);
}
}
}
This will help when i need send some information for other players and not for a player that send a message for the server.
Example:
1 - We have Player A, B, C, D, E
2 - Player A is GM and he send the command: "/killall"
3 - The method "killall" is received by the server and execute:
- Code: Select all
Broadcast("DISCONNECT_FROM_SERVER");
4 - All the clients will receive the message, and the GM too
5 - If i have the command that i suggest, i can use:
- Code: Select all
Broadcast(player.id, "DISCONNECT_FROM_SERVER");
6 - And only the GM not receive the message
This is simple example, it can help my life and the others developers too, because we dont need player a loop and after send the message to a specific player, i need use much more code to make it and more process.
What playerio team think about?