#include <ChannelProvider.h>
Public Member Functions | |
ChannelProvider () | |
Creates a new ChannelProvider, with no active channels. | |
void | addConnection (int channel, Connection *conn) |
Adds a Connection to a channel. | |
void | removeConnection (int channel, Connection *conn) |
Removes a Connection from a channel. | |
void | removeFromAll (Connection *conn) |
Removes the given Connection from all of the channels. | |
void | disbandChannel (int channel) |
Removes all of the Connections from a channel. | |
int | numConnections (int channel) const |
Returns the number of Connections currently part of the given channel. | |
void | sendToChannel (int channel, int from, const Packet &packet, Connection *exclude, bool reliable) const |
Sends a packet to everyone on a channel. | |
void | sendToChannel (ChannelPacket &packet, Connection *exclude, bool reliable) const |
Works just like #sendToChannel( int, int, Packet&, Connection* ), except it takes an already created ChannelPacket. | |
Static Public Attributes | |
const int | MIN_CHANNEL = 0 |
The minimum valid channel number. | |
const int | MAX_CHANNEL = 255 |
The maximum valid channel number. |
This class is part of the high-level GNE API, and is mostly meant to be used by the Server class, but users of the mid-level API who do not wish to use the Server/Client API may also find this class useful as well.
The valid range of channels is from 0 to 255, both sides inclusive. These values are reflected in the MIN_CHANNEL and MAX_CHANNEL static members.
This class is entirely thread-safe. The methods can all be called from multiple threads concurrently, and will retain their expected behaviors in all cases. The obvious exception is that no threads can be accessing the object if another thread is destroying or has destroyed the object.
|
Adds a Connection to a channel. If the channel does not exist, one is transparently created (in other words, you do not need to explicitly open new channels). If one of the two parameters are invalid, no action is taken. In the debugging version of the library, an assert will fail in that case.
|
|
Removes all of the Connections from a channel. If the channel parameter is invalid, no action is taken, but in the debugging version of the library, an assert will fail.
|
|
Removes a Connection from a channel. If the channel does not exist, or if the Connection is not a member of the channel, this method will have no effect. If one of the two parameters are invalid, no action is taken. In the debugging version of the library, an assert will fail in that case.
|
|
Removes the given Connection from all of the channels. Useful for when the Connection shuts down. |
|
Sends a packet to everyone on a channel. Creates a ChannelPacket with the specified channel and sends it to all Connections, except the one specified. Excluding a Connection is useful for when you want to send to everyone but the Connection who sent the packet. It is acceptable if the channel does not exist -- in this case no packets will be sent. It is also acceptable if the exclude parameter does not exist in the channel -- in this case, the packet will be sent to all Connections. If the channel parameter is invalid, no action is taken, but in the debugging version of the library, an assert will fail.
|