internal static Task Close(this ITransportConnection connection, string connectionId)
        {
            var command = new Command
            {
                Type = CommandType.Disconnect
            };

            return connection.Send(new ConnectionMessage(connectionId, command));
        }
        internal static Task Abort(this ITransportConnection connection, string connectionId)
        {
            var command = new Command
            {
                Type = CommandType.Abort
            };

            return connection.Publish(new ConnectionMessage(connectionId, command));
        }
        /// <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);
        }
Exemple #4
0
        /// <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)
        {
            var command = new Command
            {
                Type = CommandType.AddToGroup,
                Value = CreateQualifiedName(groupName),
                WaitForAck = true
            };

            return _connection.Publish(connectionId, command);
        }
Exemple #5
0
        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;
            }
        }
Exemple #6
0
        private void ProcessCommand(Command command)
        {
            switch (command.Type)
            {
                case CommandType.AddToGroup:
                    {
                        var groupData = _serializer.Parse<GroupData>(command.Value);

                        if (EventAdded != null)
                        {
                            _groups.Add(groupData.Name);
                            EventAdded(groupData.Name, groupData.Cursor);
                        }
                    }
                    break;
                case CommandType.RemoveFromGroup:
                    {
                        var groupData = _serializer.Parse<GroupData>(command.Value);

                        if (EventRemoved != null)
                        {
                            _groups.Remove(groupData.Name);
                            EventRemoved(groupData.Name);
                        }
                    }
                    break;
                case CommandType.Disconnect:
                    _disconnected = true;
                    break;
                case CommandType.Abort:
                    _aborted = true;
                    break;
            }
        }