A message sent to one more connections.
        /// <summary>
        /// Sends a message to all connections subscribed to the specified signal. An example of signal may be a
        /// specific connection id, or fully qualified group name (Use <see cref="IGroupManager"/> to manipulate groups).
        /// </summary>
        /// <param name="connection">The connection</param>
        /// <param name="signal">The signal to send to.</param>
        /// <param name="value">The value to publish.</param>
        /// <param name="exclude">The list of connection ids to exclude</param>
        /// <returns>A task that represents when the broadcast is complete.</returns>
        public static Task Send(this IConnection connection, string signal, object value, params string[] exclude)
        {
            var message = new ConnectionMessage(signal, value)
            {
                ExcludedSignals = exclude
            };

            return connection.Send(message);
        }
        /// <summary>
        /// Sends a message to all connections subscribed to the specified signal. An example of signal may be a
        /// specific connection id, or fully qualified group name (Use <see cref="IGroupManager"/> to manipulate groups).
        /// </summary>
        /// <param name="connection">The connection</param>
        /// <param name="signal">The signal to send to.</param>
        /// <param name="value">The value to publish.</param>
        /// <param name="exclude">The list of connection ids to exclude</param>
        /// <returns>A task that represents when the broadcast is complete.</returns>
        public static Task Send(this IConnection connection, string signal, object value, params string[] exclude)
        {
            var message = new ConnectionMessage(signal, value)
            {
                ExcludedSignals = exclude
            };

            return(connection.Send(message));
        }
示例#3
0
        /// <summary>
        /// Sends a value to the specified group.
        /// </summary>
        /// <param name="groupName">The name of the group.</param>
        /// <param name="value">The value to send.</param>
        /// <returns>A task that represents when send is complete.</returns>
        public Task Send(string groupName, object value, params string[] exclude)
        {
            var qualifiedName = CreateQualifiedName(groupName);
            var message       = new ConnectionMessage(qualifiedName, value)
            {
                ExcludedSignals = exclude
            };

            return(_connection.Send(message));
        }
示例#4
0
        /// <summary>
        /// Sends a value to the specified group.
        /// </summary>
        /// <param name="groupName">The name of the group.</param>
        /// <param name="value">The value to send.</param>
        /// <returns>A task that represents when send is complete.</returns>
        public Task Send(string groupName, object value, params string[] exclude)
        {
            var qualifiedName = CreateQualifiedName(groupName);
            var message = new ConnectionMessage(qualifiedName, value)
            {
                ExcludedSignals = exclude
            };

            return _connection.Send(message);
        }
示例#5
0
        /// <summary>
        /// Sends a value to the specified group.
        /// </summary>
        /// <param name="groupNames">The names of the groups.</param>
        /// <param name="value">The value to send.</param>
        /// <param name="excludeConnectionIds">The list of connection ids to exclude</param>
        /// <returns>A task that represents when send is complete.</returns>
        public Task Send(IList <string> groupNames, object value, params string[] excludeConnectionIds)
        {
            if (groupNames == null)
            {
                throw new ArgumentNullException("groupNames");
            }

            var message = new ConnectionMessage(groupNames.Select(groupName => CreateQualifiedName(groupName)).ToList(),
                                                value,
                                                PrefixHelper.GetPrefixedConnectionIds(excludeConnectionIds));

            return(_connection.Send(message));
        }
        /// <summary>
        /// Broadcasts a value to all connections, excluding the connection ids specified.
        /// </summary>
        /// <param name="connection">The connection</param>
        /// <param name="value">The value to broadcast.</param>
        /// <param name="excludeConnectionIds">The list of connection ids to exclude</param>
        /// <returns>A task that represents when the broadcast is complete.</returns>
        public static Task Broadcast(this IConnection connection, object value, params string[] excludeConnectionIds)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            var message = new ConnectionMessage(connection.DefaultSignal,
                                                value,
                                                PrefixHelper.GetPrefixedConnectionIds(excludeConnectionIds));

            return connection.Send(message);
        }
        /// <summary>
        /// Sends a value to the specified group.
        /// </summary>
        /// <param name="groupNames">The names of the groups.</param>
        /// <param name="value">The value to send.</param>
        /// <param name="excludeConnectionIds">The list of connection ids to exclude</param>
        /// <returns>A task that represents when send is complete.</returns>
        public Task Send(IList<string> groupNames, object value, params string[] excludeConnectionIds)
        {
            if (groupNames == null)
            {
                throw new ArgumentNullException("groupNames");
            }

            var message = new ConnectionMessage(groupNames.Select(groupName => CreateQualifiedName(groupName)).ToList(),
                                                value,
                                                PrefixHelper.GetPrefixedConnectionIds(excludeConnectionIds));

            return _connection.Send(message);
        }
示例#8
0
        /// <summary>
        /// Sends a message to all connections subscribed to the specified signal. An example of signal may be a
        /// specific connection id.
        /// </summary>
        /// <param name="connection">The connection</param>
        /// <param name="connectionId">The connectionId to send to.</param>
        /// <param name="value">The value to publish.</param>
        /// <param name="excludeConnectionIds">The list of connection ids to exclude</param>
        /// <returns>A task that represents when the broadcast is complete.</returns>
        public static Task Send(this IConnection connection, string connectionId, object value, params string[] excludeConnectionIds)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            var message = new ConnectionMessage(PrefixHelper.GetConnectionId(connectionId),
                                                value,
                                                PrefixHelper.GetPrefixedConnectionIds(excludeConnectionIds));

            return connection.Send(message);
        }
示例#9
0
        /// <summary>
        /// Broadcasts a value to all connections, excluding the connection ids specified.
        /// </summary>
        /// <param name="connection">The connection</param>
        /// <param name="value">The value to broadcast.</param>
        /// <param name="excludeConnectionIds">The list of connection ids to exclude</param>
        /// <returns>A task that represents when the broadcast is complete.</returns>
        public static Task Broadcast(this IConnection connection, object value, params string[] excludeConnectionIds)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            var message = new ConnectionMessage(connection.DefaultSignal,
                                                value,
                                                PrefixHelper.GetPrefixedConnectionIds(excludeConnectionIds));

            return(connection.Send(message));
        }
示例#10
0
        /// <summary>
        /// Sends a value to the specified group.
        /// </summary>
        /// <param name="groupName">The name of the group.</param>
        /// <param name="value">The value to send.</param>
        /// <param name="excludeConnectionIds">The list of connection ids to exclude</param>
        /// <returns>A task that represents when send is complete.</returns>
        public Task Send(string groupName, object value, params string[] excludeConnectionIds)
        {
            if (string.IsNullOrEmpty(groupName))
            {
                throw new ArgumentException((Resources.Error_ArgumentNullOrEmpty), "groupName");
            }

            var qualifiedName = CreateQualifiedName(groupName);
            var message = new ConnectionMessage(qualifiedName,
                                                value,
                                                PrefixHelper.GetPrefixedConnectionIds(excludeConnectionIds));

            return _connection.Send(message);
        }
示例#11
0
        /// <summary>
        /// Sends a message to all connections subscribed to the specified signal. An example of signal may be a
        /// specific connection id, or fully qualified group name (Use <see cref="IGroupManager"/> to manipulate groups).
        /// </summary>
        /// <param name="connection">The connection</param>
        /// <param name="signal">The signal to send to.</param>
        /// <param name="value">The value to publish.</param>
        /// <param name="exclude">The list of connection ids to exclude</param>
        /// <returns>A task that represents when the broadcast is complete.</returns>
        public static Task Send(this IConnection connection, string signal, object value, params string[] exclude)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            var message = new ConnectionMessage(signal, value)
            {
                ExcludedSignals = exclude
            };

            return connection.Send(message);
        }
示例#12
0
        /// <summary>
        /// Sends a value to the specified group.
        /// </summary>
        /// <param name="groupName">The name of the group.</param>
        /// <param name="value">The value to send.</param>
        /// <param name="excludeConnectionIds">The list of connection ids to exclude</param>
        /// <returns>A task that represents when send is complete.</returns>
        public Task Send(string groupName, object value, params string[] excludeConnectionIds)
        {
            if (String.IsNullOrEmpty(groupName))
            {
                throw new ArgumentException((Resources.Error_ArgumentNullOrEmpty), "groupName");
            }

            var qualifiedName = CreateQualifiedName(groupName);
            var message       = new ConnectionMessage(qualifiedName,
                                                      value,
                                                      PrefixHelper.GetPrefixedConnectionIds(excludeConnectionIds));

            return(_connection.Send(message));
        }
示例#13
0
        /// <summary>
        /// Sends a message to all connections subscribed to the specified signal. An example of signal may be a
        /// specific connection id, or fully qualified group name (Use <see cref="IGroupManager"/> to manipulate groups).
        /// </summary>
        /// <param name="connection">The connection</param>
        /// <param name="signal">The signal to send to.</param>
        /// <param name="value">The value to publish.</param>
        /// <param name="exclude">The list of connection ids to exclude</param>
        /// <returns>A task that represents when the broadcast is complete.</returns>
        public static Task Send(this IConnection connection, string signal, object value, params string[] exclude)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            var message = new ConnectionMessage(signal, value)
            {
                ExcludedSignals = exclude
            };

            return(connection.Send(message));
        }
示例#14
0
        /// <summary>
        /// Sends a value to the specified group.
        /// </summary>
        /// <param name="groupName">The name of the group.</param>
        /// <param name="value">The value to send.</param>
        /// <param name="exclude"></param>
        /// <returns>A task that represents when send is complete.</returns>
        public Task Send(string groupName, object value, params string[] exclude)
        {
            if (groupName == null)
            {
                throw new ArgumentNullException("groupName");
            }

            var qualifiedName = CreateQualifiedName(groupName);
            var message = new ConnectionMessage(qualifiedName, value)
            {
                ExcludedSignals = exclude
            };

            return _connection.Send(message);
        }
        /// <summary>
        /// Sends a message to all connections subscribed to the specified signal. An example of signal may be a
        /// specific connection id.
        /// </summary>
        /// <param name="connection">The connection</param>
        /// <param name="connectionId">The connectionId to send to.</param>
        /// <param name="value">The value to publish.</param>
        /// <returns>A task that represents when the broadcast is complete.</returns>
        public static Task Send(this IConnection connection, string connectionId, object value)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            if (String.IsNullOrEmpty(connectionId))
            {
                throw new ArgumentException(Resources.Error_ArgumentNullOrEmpty, "connectionId");
            }

            var message = new ConnectionMessage(PrefixHelper.GetConnectionId(connectionId),
                                                value);

            return connection.Send(message);
        }
示例#16
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));
        }
        /// <summary>
        /// Sends a message to all connections subscribed to the specified signal. An example of signal may be a
        /// specific connection id.
        /// </summary>
        /// <param name="connection">The connection</param>
        /// <param name="connectionIds">The connection ids to send to.</param>
        /// <param name="value">The value to publish.</param>
        /// <returns>A task that represents when the broadcast is complete.</returns>
        public static Task Send(this IConnection connection, IList<string> connectionIds, object value)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            if (connectionIds == null)
            {
                throw new ArgumentNullException("connectionIds");
            }

            var message = new ConnectionMessage(connectionIds.Select(c => PrefixHelper.GetConnectionId(c)).ToList(),
                                                value);

            return connection.Send(message);
        }
        /// <summary>
        /// Sends a message to all connections subscribed to the specified signal. An example of signal may be a
        /// specific connection id.
        /// </summary>
        /// <param name="connection">The connection</param>
        /// <param name="connectionIds">The connection ids to send to.</param>
        /// <param name="value">The value to publish.</param>
        /// <returns>A task that represents when the broadcast is complete.</returns>
        public static Task Send(this IConnection connection, IList <string> connectionIds, object value)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            if (connectionIds == null)
            {
                throw new ArgumentNullException("connectionIds");
            }

            var message = new ConnectionMessage(connectionIds.Select(c => PrefixHelper.GetConnectionId(c)).ToList(),
                                                value);

            return(connection.Send(message));
        }
        /// <summary>
        /// Sends a message to all connections subscribed to the specified signal. An example of signal may be a
        /// specific connection id.
        /// </summary>
        /// <param name="connection">The connection</param>
        /// <param name="connectionId">The connectionId to send to.</param>
        /// <param name="value">The value to publish.</param>
        /// <returns>A task that represents when the broadcast is complete.</returns>
        public static Task Send(this IConnection connection, string connectionId, object value)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            if (String.IsNullOrEmpty(connectionId))
            {
                throw new ArgumentException(Resources.Error_ArgumentNullOrEmpty, "connectionId");
            }

            var message = new ConnectionMessage(PrefixHelper.GetConnectionId(connectionId),
                                                value);

            return(connection.Send(message));
        }
示例#20
0
        /// <summary>
        /// Sends a value to the specified group.
        /// </summary>
        /// <param name="groupName">The name of the group.</param>
        /// <param name="value">The value to send.</param>
        /// <param name="excludeConnectionIds">The list of connection ids to exclude</param>
        /// <returns>A task that represents when send is complete.</returns>
        public Task Send(string groupName, object value, params string[] excludeConnectionIds)
        {
            if (groupName == null)
            {
                throw new ArgumentNullException("groupName");
            }

            var qualifiedName = CreateQualifiedName(groupName);
            var message = new ConnectionMessage(qualifiedName,
                                                value,
                                                PrefixHelper.GetPrefixedConnectionIds(excludeConnectionIds));

            return _connection.Send(message);
        }
示例#21
0
        /// <summary>
        /// Sends a value to the specified group.
        /// </summary>
        /// <param name="groupName">The name of the group.</param>
        /// <param name="value">The value to send.</param>
        /// <returns>A task that represents when send is complete.</returns>
        public Task Send(string groupName, object value, params string[] exclude)
        {
            if (groupName == null)
            {
                throw new ArgumentNullException("groupName");
            }

            var qualifiedName = CreateQualifiedName(groupName);
            var message = new ConnectionMessage(qualifiedName, value)
            {
                ExcludedSignals = exclude
            };

            return _connection.Send(message);
        }
示例#22
0
        public Task Send(ConnectionMessage message)
        {
            Message busMessage = CreateMessage(message.Signal, message.Value);

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

            _counters.ConnectionMessagesSentTotal.Increment();
            _counters.ConnectionMessagesSentPerSec.Increment();

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

            return _bus.Publish(busMessage);
        }