public final class Broadcast
extends java.lang.Object
Broadcast
stores a mapping from users to a list of responses.
The server backend uses a broadcast to send messages to clients to inform
them of relevant events in their channels. For instance, many chat services
inform you when someone has been removed from a chat that you're in.
You do not need to modify this file.Modifier and Type | Method | Description |
---|---|---|
static Broadcast |
connected(java.lang.String recipient) |
Creates a
Broadcast for the case when a user first connects to the server and should
be informed of their new nickname |
static Broadcast |
disconnected(java.lang.String user,
java.util.Collection<java.lang.String> recipients) |
Creates a
Broadcast for the case when a user disconnects from the server and other
clients should be informed of this fact. |
boolean |
equals(java.lang.Object o) |
|
static Broadcast |
error(Command command,
ServerResponse error) |
Creates a
Broadcast for the case where a client's Command is invalid, and the
client should be informed. |
java.util.Map<java.lang.Integer,java.util.List<java.lang.String>> |
getResponses(ServerModelApi model) |
You should not call this method yourself.
|
int |
hashCode() |
|
static Broadcast |
names(Command command,
java.util.Collection<java.lang.String> recipients,
java.lang.String owner) |
A specialized method for creating a
Broadcast in the event that a user is added to a
channel as the result of a JoinCommand or InviteCommand . |
static Broadcast |
okay(Command command,
java.util.Collection<java.lang.String> recipients) |
Creates a
Broadcast for the general case where a client's Command is accepted
by the server and should be relayed to the appropriate clients. |
java.lang.String |
toString() |
public static Broadcast okay(Command command, java.util.Collection<java.lang.String> recipients)
Broadcast
for the general case where a client's Command
is accepted
by the server and should be relayed to the appropriate clients.command
- The Command
whose effects to broadcastrecipients
- The set of user names of clients who should receive the broadcast from the
serverBroadcast
representing a set of responses to sendpublic static Broadcast error(Command command, ServerResponse error)
Broadcast
for the case where a client's Command
is invalid, and the
client should be informed.command
- The command which caused the errorerror
- The ServerResponse
that the command causedBroadcast
representing the response to sendjava.lang.IllegalArgumentException
- if error value is OKAY
public static Broadcast connected(java.lang.String recipient)
Broadcast
for the case when a user first connects to the server and should
be informed of their new nicknamerecipient
- The automatically generated nickname for the clientBroadcast
to the new clientpublic static Broadcast disconnected(java.lang.String user, java.util.Collection<java.lang.String> recipients)
Broadcast
for the case when a user disconnects from the server and other
clients should be informed of this fact.user
- The nickname of the disconnected userrecipients
- A set of nicknames of clients who should be informed of the user's
disconnection. Should not include the user who disconnected.Broadcast
representing the response to sendpublic static Broadcast names(Command command, java.util.Collection<java.lang.String> recipients, java.lang.String owner)
Broadcast
in the event that a user is added to a
channel as the result of a JoinCommand
or InviteCommand
. The resulting
Broadcast informs the relevant client of the nicknames of all other users in the channel.command
- The command issued by the client (Invite or Join)recipients
- A set of nicknames of the other users in the channel which the user is
joining, and to whom the command should be relayed.owner
- The nickname of the channel's ownerBroadcast
representing the responses to sendjava.lang.IllegalArgumentException
- if command
is not an instanceof JoinCommand
or InviteCommand
public java.util.Map<java.lang.Integer,java.util.List<java.lang.String>> getResponses(ServerModelApi model)
ServerBackend
before
dispatching the Broadcast
.model
- A class conforming to ServerModelApi
which can be used to look up user
IDs.ServerBackend
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object