Beispiel #1
0
        /// <summary>
        /// Sends a command that returns a value, allows a callback to be passed.
        /// </summary>
        /// <param name="receipient">Receipient to send to.</param>
        /// <param name="data">Data to send.</param>
        /// <param name="sender">Identity under which to send the command.</param>
        /// <param name="callback">Callback to be executed when the response is received.</param>
        /// <typeparam name="C"><see cref="Command"/> to send.</typeparam>
        /// <typeparam name="T">Type of <paramref name="data"/> needed for seralization.</typeparam>
        public void SendCommand <C, T>(EntityId receipient, T data, EntityId sender, Command.CommandMethod callback) where C : ReturnCommand
        {
            long id = ThreadSaveIdGenerator.NextId;

            ReturnCommandService.Instance.AddCallback(id, callback);

            if (sender == default(EntityId))
            {
                sender = this.Id;
            }

            SendCommand <C, T>(receipient, data, id, sender);
        }
Beispiel #2
0
        /// <summary>
        /// Sends a command that returns a value, allows a callback to be passed.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="callback"></param>
        /// <typeparam name="T"></typeparam>
        public void SendGetCommand(CommandData data, Command.CommandMethod callback)
        {
            if (String.IsNullOrEmpty(data.Type))
            {
                throw new ArgumentException("Command identifier has not been set");
            }

            long id = ThreadSaveIdGenerator.NextId;

            ReturnCommandService.Instance.AddCallback(id, callback);

            if (data.SenderId == default(EntityId))
            {
                data.SenderId = this.Id;
            }

            SendCommand(data);
        }
Beispiel #3
0
 public void AddCallback(long id, Command.CommandMethod callback)
 {
     callbacks.Add(id, callback);
 }
Beispiel #4
0
 /// <summary>
 /// Sends a command that returns a value, allows a callback to be passed.
 /// </summary>
 /// <param name="receipient">Receipient to send to.</param>
 /// <param name="data">Data to send.</param>
 /// <param name="callback">Callback to be executed when the response is received.</param>
 /// <typeparam name="C"><see cref="Command"/> to send.</typeparam>
 /// <typeparam name="T">Type of <paramref name="data"/> needed for seralization.</typeparam>
 public void SendCommand <C, T>(EntityId receipient, T data, Command.CommandMethod callback) where C : ReturnCommand
 {
     SendCommand <C, T>(receipient, data, default(EntityId), callback);
 }