Class ChannelManager

java.lang.Object
nl.andrewl.concord_server.channel.ChannelManager

public class ChannelManager extends Object
This manager is responsible for keeping track of all the channels in the server, and controlling modifications to them.
  • Field Details

    • server

      private final ConcordServer server
    • channelNameMap

      private final Map<String,Channel> channelNameMap
    • channelIdMap

      private final Map<UUID,Channel> channelIdMap
    • privateChannels

      private final Map<Set<UUID>,Channel> privateChannels
    • privateChannelCollection

      private final org.dizitart.no2.NitriteCollection privateChannelCollection
  • Constructor Details

  • Method Details

    • getChannels

      public Set<Channel> getChannels()
    • getDefaultChannel

      public Optional<Channel> getDefaultChannel()
    • addChannel

      public void addChannel(Channel channel)
    • removeChannel

      public void removeChannel(Channel channel)
    • getChannelByName

      public Optional<Channel> getChannelByName(String name)
    • getChannelById

      public Optional<Channel> getChannelById(UUID id)
    • moveToChannel

      public void moveToChannel(ClientThread client, Channel channel)
      Moves a client to the given channel. This involves removing the client from whatever channel they're currently in, if any, moving them to the new channel, and sending them a message to indicate that it has been done.
      Parameters:
      client - The client to move.
      channel - The channel to move the client to.
    • getPrivateChannel

      public Channel getPrivateChannel(Set<UUID> clientIds)
      Gets or creates a private channel for the given client ids to be able to communicate together. No other clients are allowed to access the channel.
      Parameters:
      clientIds - The id of each client which should have access to the channel.
      Returns:
      The private channel.
    • getPrivateChannel

      public Optional<Channel> getPrivateChannel(UUID clientId, UUID channelId)
      Gets a private channel, given the id of a client who is part of the channel, and the id of the channel.
      Parameters:
      clientId - The id of the client that's requesting the channel.
      channelId - The id of the private channel.
      Returns:
      The private channel.
    • getPrivateChannelFromDatabase

      private Channel getPrivateChannelFromDatabase(Set<UUID> clientIds)
      Gets and instantiates a private channel from information stored in the "private-channels" collection of the database, or creates it if it does not exist yet.
      Parameters:
      clientIds - The set of client ids that the channel is for.
      Returns:
      The private channel.