/// <summary> /// Adds a Command to this behavior that will be executed solely on the server and returned to all clients in the session /// </summary> /// <param name="serverExecution">The delegate to the code that will be executed by the server</param> /// <param name="applyServerResult">The delegate to the code that will be executed by all clients in the session when server returns</param> /// <param name="dataType">The Type of the data exchanged between the clients and server</param> /// <param name="dataTransferOptions">Tells how the command orders are transfered throught the network</param> protected void AddServerCommand(Command.ServerCommand serverExecution, Command.ApplyServerCommand applyServerResult, Type dataType, DataTransferOptions dataTransferOptions) { AddCommand(Command.CreateServerCommand(serverExecution, applyServerResult, dataType, dataTransferOptions)); }
/// <summary> /// Adds a Command to this behavior that will be executed solely on the server and returned to all clients in the session /// </summary> /// <param name="condition"></param> /// <param name="serverExecution">The delegate to the code that will be executed by the server</param> /// <param name="applyServerResult">The delegate to the code that will be executed by all clients in the session when server returns</param> /// <param name="dataType">The Type of the data exchanged between the clients and server</param> /// <param name="dataTransferOptions">Tells how the command orders are transfered throught the network</param> /// <param name="frequency"></param> protected void AddServerCommand(Condition condition, Command.ServerCommand serverExecution, Command.ApplyServerCommand applyServerResult, Type dataType, DataTransferOptions dataTransferOptions, ExecutionFrequency frequency) { AddCommand(Command.CreateServerCommand(condition, serverExecution, applyServerResult, dataType, dataTransferOptions, frequency)); }
/// <summary> /// Adds a Command to this behavior that will be executed solely on the server and returned to all clients in the session /// </summary> /// <param name="condition"></param> /// <param name="serverExecution">The delegate to the code that will be executed by the server</param> protected void AddServerCommand(Condition condition, Command.ServerCommand serverExecution) { AddCommand(Command.CreateServerCommand(condition, serverExecution)); }
/// <summary> /// Adds a Command to this behavior that will be executed solely on the server and returned to all clients in the session /// </summary> /// <param name="condition"></param> /// <param name="serverExecution">The delegate to the code that will be executed by the server</param> /// <param name="frequency"></param> protected void AddServerCommand(Condition condition, Command.ServerCommand serverExecution, ExecutionFrequency frequency) { AddCommand(Command.CreateServerCommand(condition, serverExecution, frequency)); }
/// <summary> /// Asks the Session to send a remote command call on all session clients /// </summary> /// <param name="command">The command that should be executed</param> public override void ExecuteServerCommandOnClients(Command command) { if (command.NetworkValue == null) _executeCommands.Add(command, Constants.ExecuteServerCommandOnClientsNoDataExchanged); else _executeCommands.Add(command, Constants.ExecuteServerCommandOnClientsDataExchanged); }
/// <summary> /// Adds a Command to this behavior that will be executed solely on the server and returned to all clients in the session /// </summary> /// <param name="serverExecution">The delegate to the code that will be executed by the server</param> protected void AddServerCommand(Command.ServerCommand serverExecution) { AddCommand(Command.CreateServerCommand(serverExecution)); }
/// <summary> /// Adds a Command to this behavior that will be executed solely on the client /// </summary> /// <param name="clientCommand">The delegate to the code that will be executed by the client</param> /// <param name="condition"></param> protected void AddLocalCommand(Condition condition, Command.ClientCommand clientCommand) { AddCommand(Command.CreateLocalCommand(condition, clientCommand)); }
/// <summary> /// Asks the Session to send a remote command call on all session clients /// </summary> /// <param name="command">The command that should be executed</param> public override void ExecuteServerCommandOnClients(Command command) { if (!IsHost) throw new CoreException("Only the host can execute server commands on clients"); if (command.NetworkValue != null) _packetWriter.Write(Constants.ExecuteServerCommandOnClientsDataExchanged); else _packetWriter.Write(Constants.ExecuteServerCommandOnClientsNoDataExchanged); _packetWriter.Write(command.Id); if (command.NetworkValue != null) { WriteNetworkValue(ref _packetWriter, command.NetworkValue); } ((LocalNetworkGamer) _networkSession.Host).SendData(_packetWriter, ConvertToSendDataOptions(command.TransferOptions)); }
/// <summary> /// Asks the Session to send a remote command call on the session host /// </summary> /// <param name="command">The command that should be executed</param> public override void ExecuteCommandOnServer(Command command) { _outgoingMessage = LidgrenSessionManager.Client.CreateMessage(); if (command.NetworkValue != null) { _outgoingMessage.Write((byte)LidgrenMessages.ExecuteCommandOnServerDataExchanged); } else { _outgoingMessage.Write((byte)LidgrenMessages.ExecuteCommandOnServerNoDataExchanged); } _outgoingMessage.Write(command.Id); if (command.NetworkValue != null) WriteNetworkValue(ref _outgoingMessage, command.NetworkValue); LidgrenSessionManager.Client.SendMessage(_outgoingMessage, ConvertToNetDeliveryMethod(command.TransferOptions)); }
/// <summary> /// Adds a Command to this behavior that will be executed solely on the client /// </summary> /// <param name="clientCommand">The delegate to the code that will be executed by the client</param> protected void AddLocalCommand(Command.ClientCommand clientCommand) { AddCommand(Command.CreateLocalCommand(clientCommand)); }
/// <summary> /// Asks the Session to send a remote command call on all session clients /// </summary> /// <param name="command">The command that should be executed</param> public override void ExecuteServerCommandOnClients(Command command) { if (!IsHost) throw new CoreException("Only the host can execute server commands on clients"); _outgoingMessage = LidgrenSessionManager.Server.CreateMessage(); if (command.NetworkValue != null) { _outgoingMessage.Write((byte)LidgrenMessages.ExecuteServerCommandOnClientsDataExchanged); } else { _outgoingMessage.Write((byte) LidgrenMessages.ExecuteServerCommandOnClientsNoDataExchanged); } _outgoingMessage.Write(command.Id); if (command.NetworkValue != null) { WriteNetworkValue(ref _outgoingMessage, command.NetworkValue); } LidgrenSessionManager.Server.SendToAll(_outgoingMessage, ConvertToNetDeliveryMethod(command.TransferOptions)); }
public override void SynchronizeCommandOnClients(Command command) { _outgoingMessage = LidgrenSessionManager.Server.CreateMessage(); _outgoingMessage.Write((byte)LidgrenMessages.SendCommandsToClients); _outgoingMessage.Write(command.Id); LidgrenSessionManager.Server.SendToAll(_outgoingMessage, NetDeliveryMethod.ReliableOrdered); }
public override void SynchronizeCommandOnClients(Command command) { }
/// <summary> /// Adds a new Command to the Behavior /// </summary> private void AddCommand(Command command) { command.Behavior = this; Commands.Add(command); // We register the command so that it can be executed in all player machines part of the current session SessionManager.CurrentSession.RegisterCommand(command); }
/// <summary> /// Adds a Command to this behavior that will be executed solely on the client /// </summary> /// <param name="clientCommand">The delegate to the code that will be executed by the client</param> /// <param name="condition"></param> /// <param name="frequency"></param> protected void AddLocalCommand(Condition condition, Command.ClientCommand clientCommand, ExecutionFrequency frequency) { AddCommand(Command.CreateLocalCommand(condition, clientCommand, frequency)); }
/// <summary> /// Sends a request to clients to synchronize commands created on Server /// </summary> /// <param name="command"></param> public override void SynchronizeCommandOnClients(Command command) { _packetWriter.Write(Constants.SynchronizeCommandOnClient); _packetWriter.Write(command.Id); ((LocalNetworkGamer) _networkSession.Host).SendData(_packetWriter, SendDataOptions.ReliableInOrder); }
/// <summary> /// Adds a Command to this behavior that will be executed on the client and on the server /// </summary> /// <param name="condition"></param> /// <param name="clientExecution">The delegate to the code that will be executed by the client</param> /// <param name="serverExecution">The delegate to the code that will be executed by the server</param> /// <param name="applyServerResult">The delegate to the code that will be executed by all clients in the session when server returns</param> /// <param name="dataType">The Type of the data exchanged between the clients and server</param> /// <param name="dataTransferOptions">Tells how the command orders are transfered throught the network</param> protected void AddLocalAndServerCommand(Condition condition, Command.ClientCommand clientExecution, Command.ServerCommand serverExecution, Command.ApplyServerCommand applyServerResult, Type dataType, DataTransferOptions dataTransferOptions) { AddCommand(Command.CreateLocalAndServerCommand(condition, clientExecution, serverExecution, applyServerResult, dataType, dataTransferOptions)); }
/// <summary> /// Asks the Session to send a remote command call on the session host /// </summary> /// <param name="command">The command that should be executed</param> public override void ExecuteCommandOnServer(Command command) { if (command.NetworkValue != null) _packetWriter.Write(Constants.ExecuteCommandOnServerDataExchanged); else _packetWriter.Write(Constants.ExecuteCommandOnServerNoDataExchanged); _packetWriter.Write(command.Id); if (command.NetworkValue != null) WriteNetworkValue(ref _packetWriter, command.NetworkValue); if (command.Behavior.Agent is PlayerAgent) { ((LocalNetworkGamer) ((LiveIdentifiedPlayer) ((PlayerAgent) command.Behavior.Agent).IdentifiedPlayer).LiveGamer).SendData( _packetWriter, ConvertToSendDataOptions(command.TransferOptions), _networkSession.Host); } else { ((LocalNetworkGamer) ((LiveIdentifiedPlayer) LocalPlayers[0]).LiveGamer). SendData(_packetWriter, ConvertToSendDataOptions(command.TransferOptions), _networkSession.Host); } command.WaitingForServerReply = true; }
/// <summary> /// Asks the Session to send a remote command call on the session host /// </summary> /// <param name="command">The command that should be executed</param> public override void ExecuteCommandOnServer(Command command) { command.WaitingForServerReply = true; if (command.NetworkValue == null) _executeCommands.Add(command, Constants.ExecuteCommandOnServerNoDataExchanged); else _executeCommands.Add(command, Constants.ExecuteCommandOnServerDataExchanged); }