Esempio n. 1
0
        /// <summary>
        /// Transport a <see cref="QueuedMessage"/>.
        /// </summary>
        /// <param name="message">The <see cref="IMessage"/> to transport.</param>
        /// <returns>An awaitable object representing the send operation.</returns>
        public async Task SendMessageAsync(QueuedMessage message)
        {
            try
            {
                var recipient = message.Envelope.Recipient as FtpPeer;

                if (recipient == null)
                {
                    throw new InvalidOperationException("The FTP Transporter cannot send a message to a non FtpPeer.");
                }

                var clientConnectTask = this._clientFactory.ConnectAsync(recipient);

                var messageContent = this.Serialiser.Serialise(message.Envelope);

                var client = await clientConnectTask;

                await client.SendMessageAsync(messageContent);

                this.MessageSent(message, messageContent);
            }
            catch (Exception exception)
            {
                if (this.MessageFailedToSend != null)
                {
                    this.MessageFailedToSend(exception, message);
                }
            }
        }
Esempio n. 2
0
 public void BroadcastMessageSent(QueuedMessage sentMessage)
 {
     this.Clients.All.messageSent(sentMessage);
 }
Esempio n. 3
0
 public void BroadcastMessageQueued(QueuedMessage queuedMessage)
 {
     this.Clients.All.messageQueued(queuedMessage);
 }