예제 #1
0
        protected InvokeSourceBase(object sender, Group @group, string name, ReplyCallback onReply)
        {
            this.PluginName = "Bot";

            this._onReply = onReply;
            this.Sender = sender;
            this.Group = @group;
            this.Name = name;
        }
        static void InnerSend <TReply>(IBus bus, object message, Action <TReply> replyHandler, TimeSpan timeout, Action timeoutAction = null)
        {
            if (bus == null)
            {
                throw new ArgumentNullException("bus", "You cannot call these methods without a bus instance");
            }
            if (message == null)
            {
                throw new ArgumentNullException("message", "You cannot call these methods without a message");
            }
            if (replyHandler == null)
            {
                throw new ArgumentNullException("replyHandler", "Please specify a reply handler");
            }

            var correlationId = Guid.NewGuid().ToString();

            bus.AttachHeader(message, Headers.CorrelationId, correlationId);

            var replyCallback = new ReplyCallback
            {
                Callback         = replyHandler,
                RegistrationTime = DateTime.UtcNow,
                MaxCallbackAge   = timeout,
                TimeoutCallback  = timeoutAction,
            };
            var key = GetKey(correlationId, typeof(TReply));

            if (TransactionContext.Current != null)
            {
                TransactionContext.Current.DoCommit +=
                    () => registeredReplyHandlers.TryAdd(key, replyCallback);
            }
            else
            {
                registeredReplyHandlers.TryAdd(key, replyCallback);
            }

            bus.Send(message);
        }
예제 #3
0
 public PlayerInvokeSource(Player player, PlayerInvokeOrigin origin, ReplyCallback onReply)
     : base(player.ChatName, onReply)
 {
     this.Player = player;
     this.Origin = origin;
 }
예제 #4
0
 internal static extern ErrorCode SendLaunchRequestAsync(IntPtr context, SafeAppControlHandle appControl,
                                                         ResultCallback resultCallback, ReplyCallback replyCallback, IntPtr userData);
예제 #5
0
 internal static extern ErrorCode SendLaunchRequest(SafeAppControlHandle handle, ReplyCallback callback, IntPtr userData);
예제 #6
0
 public ConsoleInvokeSource(ReplyCallback onReply)
     : base("console", onReply)
 {
 }
 public ReplyMessageHandler(ReplyCallback replyCallbackToUse, string correlationId)
 {
     this.replyCallbackToUse = replyCallbackToUse;
     this.correlationId      = correlationId;
 }
예제 #8
0
 protected InvokeSourceBase(string name, ReplyCallback onReply)
 {
     this.Name     = name;
     this._onReply = onReply;
 }
예제 #9
0
 protected InvokeSourceBase(string name, ReplyCallback onReply)
 {
     this.Name = name;
     this._onReply = onReply;
 }
예제 #10
0
 public ExternalInvokeSource(object sender, Group @group, string name, ReplyCallback onReply)
     : base(sender, @group, name, onReply)
 {
 }
예제 #11
0
 public PlayerInvokeSource(Player player, PlayerInvokeOrigin origin, ReplyCallback onReply)
     : base(player.ChatName, onReply)
 {
     this.Player = player;
     this.Origin = origin;
 }
예제 #12
0
 public PlayerInvokeSource(object sender, Group @group, Player player, ReplyCallback onReply)
     : base(sender, @group, player.Username, onReply)
 {
     this.Player = player;
 }