Ejemplo n.º 1
0
        /// <summary>
        /// Returns a dynamic representation of the specified group.
        /// </summary>
        /// <param name="groupName">The name of the group</param>
        /// <param name="excludeConnectionIds">The list of connection ids to exclude</param>
        /// <returns>A dynamic representation of the specified group.</returns>
        public dynamic Group(string groupName, params string[] excludeConnectionIds)
        {
            if (string.IsNullOrEmpty(groupName))
            {
                throw new ArgumentException(Resources.Error_ArgumentNullOrEmpty, "groupName");
            }

            return(new GroupProxy(_send, groupName, _hubName, PrefixHelper.GetPrefixedConnectionIds(excludeConnectionIds)));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns a dynamic representation of the specified groups.
        /// </summary>
        /// <param name="groupNames">The names of the groups.</param>
        /// <param name="excludeConnectionIds">The list of connection ids to exclude</param>
        /// <returns>A dynamic representation of the specified groups.</returns>
        public dynamic Groups(IList <string> groupNames, params string[] excludeConnectionIds)
        {
            if (groupNames == null)
            {
                throw new ArgumentNullException("groupNames");
            }

            return(new MultipleSignalProxy(Connection,
                                           Invoker,
                                           groupNames,
                                           HubName,
                                           PrefixHelper.HubGroupPrefix,
                                           PrefixHelper.GetPrefixedConnectionIds(excludeConnectionIds)));
        }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
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");
            }

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

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

            return(connection.Send(message));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Returns a dynamic representation of all clients except the calling client ones specified.
 /// </summary>
 /// <param name="excludeConnectionIds">The list of connection ids to exclude</param>
 /// <returns>A dynamic representation of all clients except the calling client ones specified.</returns>
 public dynamic AllExcept(params string[] excludeConnectionIds)
 {
     return(new ClientProxy(Connection, Invoker, HubName, PrefixHelper.GetPrefixedConnectionIds(excludeConnectionIds)));
 }