Example #1
0
        //  Send the messageContent to the receiver
        public async Task <string> SendUserMessage(string messageId, string sender, string receiver, string messageContent)
        {
            //  Create a task and wait for the receiver client to complete it.
            var ackInfo = _ackHandler.CreateAck();
            await Clients.User(receiver)
            .SendAsync("displayUserMessage", messageId, sender, messageContent, ackInfo.AckId);

            //  Return the task result to the client.
            return(await ackInfo.AckTask);
        }
Example #2
0
        private Task SendMessage(string key, object value)
        {
            Message message = CreateMessage(key, value);

            _msgsSentTotalCounter.SafeIncrement();
            _msgsSentPerSecCounter.SafeIncrement();

            if (message.WaitForAck)
            {
                Task ackTask = _ackHandler.CreateAck(message.CommandId);
                return(_bus.Publish(message).Then(task => task, ackTask));
            }

            return(_bus.Publish(message));
        }
Example #3
0
        public Task Send(ConnectionMessage message)
        {
            Message busMessage = CreateMessage(message.Signal, message.Value);

            if (message.ExcludedSignals != null)
            {
                busMessage.Filter = String.Join("|", message.ExcludedSignals);
            }

            if (busMessage.WaitForAck)
            {
                Task ackTask = _ackHandler.CreateAck(busMessage.CommandId);
                return(_bus.Publish(busMessage).Then(task => task, ackTask));
            }

            return(_bus.Publish(busMessage));
        }