private static Task SendCommand(ITransportConnection connection, string connectionId, CommandType commandType) { var command = new Command { CommandType = commandType }; var message = new ConnectionMessage(PrefixHelper.GetConnectionId(connectionId), command); return connection.Send(message); }
private void ProcessCommand(Command command) { switch (command.CommandType) { case CommandType.AddToGroup: { var name = command.Value; if (EventKeyAdded != null) { _groups.Add(name); EventKeyAdded(this, name); } } break; case CommandType.RemoveFromGroup: { var name = command.Value; if (EventKeyRemoved != null) { _groups.Remove(name); EventKeyRemoved(this, name); } } break; case CommandType.Initializing: _initializing = true; break; case CommandType.Abort: _aborted = true; break; } }
/// <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 { CommandType = CommandType.AddToGroup, Value = CreateQualifiedName(groupName), WaitForAck = true }; return _connection.Send(connectionId, command); }