internal static Task Close(this ITransportConnection connection, string connectionId) { var command = new Command { CommandType = CommandType.Disconnect }; return connection.Send(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); }
/// <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); }
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; } }
public void SendCommand(Command c) { Clients.Others.CommandReceived(c); }