java.lang.Object
nl.andrewl.concord_server.channel.Channel
- All Implemented Interfaces:
Comparable<Channel>
Represents a single communication area in which messages are sent by clients
and received by all connected clients. A channel is a top-level communication
medium, and usually this is a server channel or private message between two
clients in a server.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Set<ClientThread>
The set of clients that are connected to this channel.private final UUID
private final org.dizitart.no2.NitriteCollection
A document collection which holds all messages created in this channel, indexed on id, timestamp, message, and sender's username.private String
private final ConcordServer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addClient
(ClientThread clientThread) Adds a client to this channel.int
boolean
getAsTag()
List<nl.andrewl.concord_core.msg.types.UserData>
Gets a list of information about each user in this channel.int
hashCode()
void
removeClient
(ClientThread clientThread) Removes a client from this channel.void
sendMessage
(nl.andrewl.concord_core.msg.Message msg) Sends a message to all clients that are currently connected to this channel.toString()
-
Field Details
-
server
-
id
-
name
-
connectedClients
The set of clients that are connected to this channel. -
messageCollection
private final org.dizitart.no2.NitriteCollection messageCollectionA document collection which holds all messages created in this channel, indexed on id, timestamp, message, and sender's username.
-
-
Constructor Details
-
Channel
-
-
Method Details
-
addClient
Adds a client to this channel.- Parameters:
clientThread
- The client to add.
-
removeClient
Removes a client from this channel.- Parameters:
clientThread
- The client to remove.
-
sendMessage
Sends a message to all clients that are currently connected to this channel. Makes use of the server's serializer to preemptively serialize the data once, so that clients need only write a byte array to their respective output streams.- Parameters:
msg
- The message to send.- Throws:
IOException
- If an error occurs.
-
getUserData
Gets a list of information about each user in this channel.- Returns:
- A list of
UserData
objects.
-
getAsTag
-
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Channel>
-