public bool SendGameStateMessage(GameState state) { var socket = _communicationSockets[state.Player.ID]; if (!socket.Connected) { return(false); } var message = new Message(MessageType.GameState, SerializationUtilities.ToByteArray(state)); Message.SendMessage(message, socket); return(true); }
protected async Task StartReceiverAsync(Socket socket, int playerNumber) { while (_runReceivers) { await Task.Delay(1); var message = Message.ReceiveMessage(socket); if (message.MessageType == MessageType.NodeUpgradeRequest) { var request = SerializationUtilities.FromByteArray <NodeUpgradeRequest>(message.Data); _handler.HandleNodeUpgradeRequestMessage(request, playerNumber); } } }
protected async Task StartReceiverAsync(Socket socket) { while (_runReceiver) { await Task.Delay(1); var message = Message.ReceiveMessage(socket); if (message.MessageType == MessageType.GameState) { var state = SerializationUtilities.FromByteArray <GameState>(message.Data); _handler.HandleGameStateMessage(state); } } }
public void SendAttackRequest(NodeUpgradeRequest request) { var message = new Message(MessageType.NodeUpgradeRequest, SerializationUtilities.ToByteArray(request)); Message.SendMessage(message, _commsSocket); }