コード例 #1
0
ファイル: ConnectionExtensions.cs プロジェクト: rustd/SignalR
        internal static Task Close(this ITransportConnection connection, string connectionId)
        {
            var command = new Command
            {
                CommandType = CommandType.Disconnect
            };

            return connection.Send(new ConnectionMessage(connectionId, command));
        }
コード例 #2
0
ファイル: GroupManager.cs プロジェクト: Kazzje/SignalR
        /// <summary>
        /// Removes a connection from the specified group.
        /// </summary>
        /// <param name="connectionId">The connection id to remove from the group.</param>
        /// <param name="groupName">The name of the group</param>
        /// <returns>A task that represents the connection id being removed from the group.</returns>
        public Task Remove(string connectionId, string groupName)
        {
            var command = new Command
            {
                Type = CommandType.RemoveFromGroup,
                Value = CreateQualifiedName(groupName),
                WaitForAck = true
            };

            return _connection.Send(connectionId, command);
        }
コード例 #3
0
ファイル: GroupManager.cs プロジェクト: nonintanon/SignalR
        /// <summary>
        /// Adds a connection to the specified group. 
        /// </summary>
        /// <param name="connectionId">The connection id to add to the group.</param>
        /// <param name="groupName">The name of the group</param>
        /// <returns>A task that represents the connection id being added to the group.</returns>
        public Task Add(string connectionId, string groupName)
        {
            if (connectionId == null)
            {
                throw new ArgumentNullException("connectionId");
            }

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

            var command = new Command
            {
                Type = CommandType.AddToGroup,
                Value = CreateQualifiedName(groupName),
                WaitForAck = true
            };

            return _connection.Send(connectionId, command);
        }
コード例 #4
0
ファイル: Connection.cs プロジェクト: Kazzje/SignalR
        private void ProcessCommand(Command command)
        {
            switch (command.Type)
            {
                case CommandType.AddToGroup:
                    {
                        var name = command.Value;

                        if (EventAdded != null)
                        {
                            _groups.Add(name);
                            EventAdded(name);
                        }
                    }
                    break;
                case CommandType.RemoveFromGroup:
                    {
                        var name = command.Value;

                        if (EventRemoved != null)
                        {
                            _groups.Remove(name);
                            EventRemoved(name);
                        }
                    }
                    break;
                case CommandType.Disconnect:
                    _disconnected = true;
                    break;
                case CommandType.Abort:
                    _aborted = true;
                    break;
            }
        }
コード例 #5
0
ファイル: ControlHub.cs プロジェクト: altinokdarici/MyRobot
 public void SendCommand(Command c)
 {
     Clients.Others.CommandReceived(c);
 }