com.planet_ink.coffee_mud.Libraries.interfaces
Interface ChannelsLibrary

All Superinterfaces:
java.lang.Cloneable, CMLibrary, CMObject, java.lang.Comparable<CMObject>
All Known Implementing Classes:
CMChannels

public interface ChannelsLibrary
extends CMLibrary

The main chat channels management library. This is one of the older libraries in the system, and as such, still reflects the use of indexed vectors that was common. It still makes sense given the way those numbers are used in CMMsg message codes to identify the channels. Over the years, the ability to filter the channels by user was added, along with flags to automatically insert information or enable other parts of the system to generate channel messages.


Nested Class Summary
static class ChannelsLibrary.ChannelFlag
          The channel flags that define extra stuff that appears in or gets automatically sent on a given channel.
static interface ChannelsLibrary.ChannelMsg
          The entry for the channel que, containing the CMMsg object that was sent as the original message as well as the timestamp when it was sent.
static interface ChannelsLibrary.CMChannel
          Basic Channel definition
 
Method Summary
 void channelQueUp(int channelNumber, CMMsg msg)
          Adds the given channel message CMMsg event message to the que for the given channel number.
 java.util.List<Session> clearInvalidSnoopers(Session mySession, int channelNumber)
          Searches all users online for any sessions that are snooping on the given session, and also are not permitted to read the given channel number.
 void createAndSendChannelMessage(MOB mob, java.lang.String channelName, java.lang.String message, boolean systemMsg)
          Creates and sends the given string message on the channel with the given name to all sessions who are allowed to receive the message from the given sender.
 ChannelsLibrary.CMChannel createNewChannel(java.lang.String name, java.lang.String i3Name, java.lang.String imc2Name, java.lang.String mask, java.util.Set<ChannelsLibrary.ChannelFlag> flags, java.lang.String colorOverrideANSI, java.lang.String colorOverrideWords)
          Creates a new channel object.
 java.lang.String findChannelName(java.lang.String channelName)
          Returns the official channel name of the channel with the given name or which starts with the given name.
 ChannelsLibrary.CMChannel getChannel(int channelNumber)
          Returns the CMChannel object for the given registered channel from 0 - getNumChannels(); Basically this is almost all you need, but there's more....
 int getChannelCodeNumber(java.lang.String channelName)
          Returns the bitmask appropriate to the channel of the given name, or which starts with the given string.
 int getChannelIndex(java.lang.String channelName)
          Returns the official index number of the channel with the given name or which starts with the given name.
 java.lang.String[] getChannelNames()
          Returns an array of all the names of all the channels.
 java.util.List<ChannelsLibrary.ChannelMsg> getChannelQue(int channelNumber, int numNewToSkip, int numToReturn)
          Generates a list of previous channel messages, in ChannelMsg object format.
 java.lang.String getExtraChannelDesc(java.lang.String channelName)
          Returns the friendly readable description of the channel with the given name, or which starts with the given string.
 java.util.List<java.lang.String> getFlaggedChannelNames(ChannelsLibrary.ChannelFlag flag)
          Returns the list of channel names that have the given ChannelFlag set.
 java.util.List<ChannelsLibrary.CMChannel> getI3ChannelsList()
          Returns all the CMChannel objects for any channels flagged as being mapped to I3.
 java.util.List<ChannelsLibrary.CMChannel> getIMC2ChannelsList()
          Returns all the CMChannel objects for any channels flagged as being mapped to IMC2.
 int getNumChannels()
          Returns the number of registered channels
 int loadChannels(java.lang.String list, java.lang.String ilist, java.lang.String imc2list)
          Clears the channels list and then reloads it from the three given comma-delimited list of coded strings.
 boolean mayReadThisChannel(MOB sender, boolean areaReq, MOB M, int channelNumber)
          Returns whether the given Mob can read a channel message from the given sender, on a particular channel.
 boolean mayReadThisChannel(MOB sender, boolean areaReq, MOB M, int channelNumber, boolean offlineOK)
          Returns whether the given Mob can read a channel message from the given sender, on a particular channel.
 boolean mayReadThisChannel(MOB sender, boolean areaReq, Session ses, int channelNumber)
          Returns whether the given Mob can read a channel message from the given sender, on a particular channel.
 boolean mayReadThisChannel(MOB M, int channelNumber, boolean zapCheckOnly)
          Returns whether the given Mob can read a channel message from the given sender, on a particular channel.
 void restoreInvalidSnoopers(Session mySession, java.util.List<Session> invalid)
          Iterates through the given list of sessions and forces them all to snoop on the given session.
 boolean sendChannelCMMsgTo(Session ses, boolean areareq, int channelNumber, CMMsg msg, MOB sender)
          Sends the given channel message from the given sender to the given session on the given channelNumbered channel.
 
Methods inherited from interface com.planet_ink.coffee_mud.Libraries.interfaces.CMLibrary
activate, getServiceClient, L, propertiesLoaded, shutdown
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.CMObject
copyOf, ID, initializeClass, name, newInstance
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

getNumChannels

int getNumChannels()
Returns the number of registered channels

Returns:
the number of registered channels
See Also:
getChannelIndex(String)

getChannel

ChannelsLibrary.CMChannel getChannel(int channelNumber)
Returns the CMChannel object for the given registered channel from 0 - getNumChannels(); Basically this is almost all you need, but there's more....

Parameters:
channelNumber - the index of the channel
Returns:
the CMChannel object
See Also:
getNumChannels()

getChannelQue

java.util.List<ChannelsLibrary.ChannelMsg> getChannelQue(int channelNumber,
                                                         int numNewToSkip,
                                                         int numToReturn)
Generates a list of previous channel messages, in ChannelMsg object format. This may potentially hit the database.

Parameters:
channelNumber - the channel id number/index
numNewToSkip - starting message number (0 based)
numToReturn - total number of messages to return
Returns:
the list of messages
See Also:
getChannelIndex(String), ChannelsLibrary.ChannelMsg

mayReadThisChannel

boolean mayReadThisChannel(MOB sender,
                           boolean areaReq,
                           MOB M,
                           int channelNumber)
Returns whether the given Mob can read a channel message from the given sender, on a particular channel.

Parameters:
sender - the sender of the channel message
areaReq - true if the message can only be read by someone in the senders Area
M - the potential receiver of the message to confirm
channelNumber - the channel index number
Returns:
true if the mob can read the senders message, false otherwise
See Also:
getNumChannels(), mayReadThisChannel(MOB, int, boolean), mayReadThisChannel(MOB, boolean, Session, int), mayReadThisChannel(MOB, boolean, MOB, int, boolean)

mayReadThisChannel

boolean mayReadThisChannel(MOB sender,
                           boolean areaReq,
                           MOB M,
                           int channelNumber,
                           boolean offlineOK)
Returns whether the given Mob can read a channel message from the given sender, on a particular channel.

Parameters:
sender - the sender of the channel message
areaReq - true if the message can only be read by someone in the senders Area
M - the potential receiver of the message to confirm
channelNumber - the channel index number
offlineOK - true if the channel reader can be read, or offline, false if they must be online
Returns:
true if the mob can read the senders message, false otherwise
See Also:
getChannelIndex(String), mayReadThisChannel(MOB, int, boolean), mayReadThisChannel(MOB, boolean, Session, int), mayReadThisChannel(MOB, boolean, MOB, int)

mayReadThisChannel

boolean mayReadThisChannel(MOB sender,
                           boolean areaReq,
                           Session ses,
                           int channelNumber)
Returns whether the given Mob can read a channel message from the given sender, on a particular channel.

Parameters:
sender - the sender of the channel message
areaReq - true if the message can only be read by someone in the senders Area
ses - the potential receiver session of the message to confirm
channelNumber - the channel index number
Returns:
true if the mob can read the senders message, false otherwise
See Also:
getNumChannels(), mayReadThisChannel(MOB, int, boolean), mayReadThisChannel(MOB, boolean, MOB, int), mayReadThisChannel(MOB, boolean, MOB, int, boolean)

mayReadThisChannel

boolean mayReadThisChannel(MOB M,
                           int channelNumber,
                           boolean zapCheckOnly)
Returns whether the given Mob can read a channel message from the given sender, on a particular channel.

Parameters:
M - the potential receiver of the message to confirm
channelNumber - the channel index number
zapCheckOnly - the channel index number
Returns:
true if the mob can read the senders message, false otherwise
See Also:
getChannelIndex(String), mayReadThisChannel(MOB, boolean, MOB, int), mayReadThisChannel(MOB, boolean, Session, int), mayReadThisChannel(MOB, boolean, MOB, int, boolean)

channelQueUp

void channelQueUp(int channelNumber,
                  CMMsg msg)
Adds the given channel message CMMsg event message to the que for the given channel number. Will cause a database write.

Parameters:
channelNumber - the channel index number
msg - the channel message msg that was sent around
See Also:
getNumChannels(), getChannelIndex(String)

getChannelIndex

int getChannelIndex(java.lang.String channelName)
Returns the official index number of the channel with the given name or which starts with the given name. It is case insensitive search.

Parameters:
channelName - the channel string to search for
Returns:
the official index number of the channel
See Also:
getNumChannels()

getChannelCodeNumber

int getChannelCodeNumber(java.lang.String channelName)
Returns the bitmask appropriate to the channel of the given name, or which starts with the given string. The bitmask is used for the individual player toggle switches.

Parameters:
channelName - the name of the channel
Returns:
the bitmask appropriate to the channel

getFlaggedChannelNames

java.util.List<java.lang.String> getFlaggedChannelNames(ChannelsLibrary.ChannelFlag flag)
Returns the list of channel names that have the given ChannelFlag set.

Parameters:
flag - the flag to find channels for
Returns:
the list of channel names with the flag set.
See Also:
ChannelsLibrary.ChannelFlag

getExtraChannelDesc

java.lang.String getExtraChannelDesc(java.lang.String channelName)
Returns the friendly readable description of the channel with the given name, or which starts with the given string. It's mostly requirements to read or write to the channel.

Parameters:
channelName - the name of the channel
Returns:
the friendly readable description of the channel

getIMC2ChannelsList

java.util.List<ChannelsLibrary.CMChannel> getIMC2ChannelsList()
Returns all the CMChannel objects for any channels flagged as being mapped to IMC2.

Returns:
all the CMChannel objects for IMC2

getI3ChannelsList

java.util.List<ChannelsLibrary.CMChannel> getI3ChannelsList()
Returns all the CMChannel objects for any channels flagged as being mapped to I3.

Returns:
all the CMChannel objects for I3

getChannelNames

java.lang.String[] getChannelNames()
Returns an array of all the names of all the channels.

Returns:
an array of all the names of all the channels.
See Also:
getNumChannels()

findChannelName

java.lang.String findChannelName(java.lang.String channelName)
Returns the official channel name of the channel with the given name or which starts with the given name. It is case insensitive search.

Parameters:
channelName - the channel string to search for
Returns:
the official channel name of the channel
See Also:
getNumChannels()

clearInvalidSnoopers

java.util.List<Session> clearInvalidSnoopers(Session mySession,
                                             int channelNumber)
Searches all users online for any sessions that are snooping on the given session, and also are not permitted to read the given channel number. It then returns all the offending sessions, after forcing them to stop snooping.

Parameters:
mySession - the session to search for snoopers of
channelNumber - the channel number to cross reference snoopers by
Returns:
all the offending sessions
See Also:
getNumChannels(), restoreInvalidSnoopers(Session, List)

restoreInvalidSnoopers

void restoreInvalidSnoopers(Session mySession,
                            java.util.List<Session> invalid)
Iterates through the given list of sessions and forces them all to snoop on the given session. This makes sense if you check the clearInvalidSnoopers method.

Parameters:
mySession - the session to search restoring snooping on
invalid - the list of sessions to force resnooping
See Also:
clearInvalidSnoopers(Session, int)

loadChannels

int loadChannels(java.lang.String list,
                 java.lang.String ilist,
                 java.lang.String imc2list)
Clears the channels list and then reloads it from the three given comma-delimited list of coded strings.

Parameters:
list - the main game channel list
ilist - the list of i3 channels
imc2list - the list of imc2 channels
Returns:
the total number of channels loaded

sendChannelCMMsgTo

boolean sendChannelCMMsgTo(Session ses,
                           boolean areareq,
                           int channelNumber,
                           CMMsg msg,
                           MOB sender)
Sends the given channel message from the given sender to the given session on the given channelNumbered channel.

Parameters:
ses - the session to send the channel message to
areareq - true if the sender and session must be in the same area, false otherwise
channelNumber - the channel index number of the message
msg - the constructed CMMsg channel message
sender - the sender of the channel message
Returns:
true if the message was sent, and false otherwise
See Also:
getNumChannels(), createAndSendChannelMessage(MOB, String, String, boolean)

createAndSendChannelMessage

void createAndSendChannelMessage(MOB mob,
                                 java.lang.String channelName,
                                 java.lang.String message,
                                 boolean systemMsg)
Creates and sends the given string message on the channel with the given name to all sessions who are allowed to receive the message from the given sender.

Parameters:
mob - the sender of the message
channelName - the name of the channel to send the message on
message - the string message to send on the channel
systemMsg - true to format as a system message, false for a normal chat message
See Also:
sendChannelCMMsgTo(Session, boolean, int, CMMsg, MOB)

createNewChannel

ChannelsLibrary.CMChannel createNewChannel(java.lang.String name,
                                           java.lang.String i3Name,
                                           java.lang.String imc2Name,
                                           java.lang.String mask,
                                           java.util.Set<ChannelsLibrary.ChannelFlag> flags,
                                           java.lang.String colorOverrideANSI,
                                           java.lang.String colorOverrideWords)
Creates a new channel object.

Parameters:
name - the channel name
i3Name - empty string, or the mapped name of the i3 channel
imc2Name - empty string, or the mapped name of the imc2 channel
mask - the zapper mask for who may read the channel
flags - the channel flags to set for the given channel
colorOverrideANSI - empty string for default, or the color code for this channel
colorOverrideWords - empty string for default, or the color code for this channel
Returns:
the newly created channel object
See Also:
ChannelsLibrary.CMChannel, ChannelsLibrary.ChannelFlag