by KVADRO » February 10th, 2019, 9:43 pm
by qugengames » February 10th, 2019, 10:19 pm
KVADRO wrote:Hi, the question is: GotMessage callback will be called sequentially for all income messages, or, for example, for two received messages there will be two concurrent invocation of GotMessage callback? (Server Side)
// Stack where I add the message storing the BasePlayer so I know who actually sent the message,
// that way I can validate the client in case they lie about a game data so I don't rely fully on what they say.
private Stack<KeyValuePair<BasePlayer, PlayerIO.GameLibrary.Message>> server_StackNETMessagePending =
new Stack<KeyValuePair<BasePlayer, PlayerIO.GameLibrary.Message>>();
public void Server_GotMessage(
BasePlayer player,
PlayerIO.GameLibrary.Message m)
{
lock (server_StackNETMessagePending)
{
server_StackNETMessagePending.Push(
new KeyValuePair<BasePlayer, PlayerIO.GameLibrary.Message>(player, m));
}
}
var keyPair = server_StackNETMessagePending.Pop();
var theMessage = keyPair.Value;
var thePlayerWhoSentTheMessage = keyPair.Key;
// #### Never trust the player, validate thePlayerWhoSentTheMessage !!
by KVADRO » February 10th, 2019, 10:24 pm