Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jChatBox.Chat
Class Chatroom

    java.lang.Object
      |
      +--jChatBox.Chat.Chatroom

All Implemented Interfaces:
  LogListener, java.io.Serializable

public class Chatroom
extends java.lang.Object
implements java.io.Serializable, LogListener

This class implements all features for jChatBox rooms.
Description :
- open/close chatroom.
- setup chatroom's name,topic,...
- reopen chatroom.
- add/remove user to chatroom.
- blackList management.
- Chatroom management (MAX users).

See Also:
  Serialized Form

Constructor Summary
`Chatroom(ChatroomParams params)` Chatroom constructor.

Method Summary
`void` | `addListener(ChatroomListener listener)` Add listener to be notified on chatroom's events.
`void` | `addMsg(Msg msg)` Adds message to Chat.
`void` | `addToBlacklist(ChatroomUser user, java.lang.String reason)` Add user to blacklist.
`void` | `addUser(ChatroomUser newUser)` Adds user to Chatroom.
`void` | `clear()` Clear chatroom content.
`void` | `close()` Close the Chatroom.
`Blacklist` | `getBlacklist()` Returns Blacklist.
`java.util.Vector` | `getChat()` Returns the whole Chat.
`java.util.Vector` | `getChat(java.lang.String username)` Returns the Chat content for an user only.
`java.util.Date` | `getDate()` Returns opening date.
`java.util.Vector` | `getListeners()` Return chatroom's listeners.
`ChatroomParams` | `getParams()` Returns Chatroom's parameters.
`int` | `getTotalUsers()` Counts Users.
`ChatroomUser` | `getUser(java.lang.String name)` Returns an User.
`java.util.Hashtable` | `getUsers()` Returns Users.
`boolean` | `isOpened()` Return true if chatroom is opened.
`protected void` | `notifyListeners(ChatroomEvent event)` Notify chatroom's listeners.
`void` | `open()` Opens the Chatroom.
`void` | `performLogin(ChatroomUser user)` LogListener dummy implementation.
`void` | `performLogout(ChatroomUser user)` Remove user from chatroom.
`void` | `removeFromBlacklist(java.lang.String ip)` Remove IP from blacklist.
`void` | `removeListener(ChatroomListener listener)` Remove listener.
`void` | `removeUser(java.lang.String name)` Removes an User.
`void` | `reOpen()` ReOpen the Chatroom (Should be used after servlet container crash ot stop).
`void` | `resetBlacklist()` Reset Blacklist.
`protected void` | `runTimer(ChatroomListener listener)` Run ChatroomTimer in a Thread.
`void` | `updateParams(ChatroomParams params)` Updates Chatroom's parameters.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Chatroom

    public Chatroom(ChatroomParams params)

  Chatroom constructor.

Method Detail

### open

    public void open()

  Opens the Chatroom.

### isOpened

    public boolean isOpened()

  Return true if chatroom is opened.

  Returns:
    false is chatroom is closed
  Since:
    2.6

### reOpen

    public void reOpen()

  ReOpen the Chatroom (Should be used after servlet container crash ot stop).
  We keep the whole thanks to Serialization but we lost all user's session
  because we're not sure HTTPSession is serializable (depending on Servlet/JSP engine).
  We update chatroom's opening date too.

### addListener

    public void addListener(ChatroomListener listener)

  Add listener to be notified on chatroom's events. If ChatroomListener is an instance of TimerListener then a new Thread is launched. Duplicated listeners (identified by listenerID) are not allowed.

  Parameters:
    `listener` -
  Since:
    2.6

### runTimer

    protected void runTimer(ChatroomListener listener)

  Run ChatroomTimer in a Thread.

  Parameters:
    `listener` -
  Since:
    2.6

### removeListener

    public void removeListener(ChatroomListener listener)

  Remove listener.

  Parameters:
    `listener` -
  Since:
    2.6

### notifyListeners

    protected void notifyListeners(ChatroomEvent event)

  Notify chatroom's listeners.

  Parameters:
    `event` -
  Since:
    2.6

### getListeners

    public java.util.Vector getListeners()

  Return chatroom's listeners.

  Returns:
    listeners.
  Since:
    2.6

### close

    public void close()

  Close the Chatroom.

### getDate

    public java.util.Date getDate()

  Returns opening date.

### addUser

    public void addUser(ChatroomUser newUser)
                 throws ChatException

  Adds user to Chatroom.
  Check Chatroom's state.
  Check blacklist entries.
  Check quota. (No apply if SYSTEM user)
  Check duplicate nickname.
  Allow SystemLogin only for SYSTEM or MODERATOR users (no case sensitive).

    `ChatException`

### getUser

    public ChatroomUser getUser(java.lang.String name)

  Returns an User.

### getTotalUsers

    public int getTotalUsers()

  Counts Users.

### getParams

    public ChatroomParams getParams()

  Returns Chatroom's parameters.

### updateParams

    public void updateParams(ChatroomParams params)

  Updates Chatroom's parameters.

### addToBlacklist

    public void addToBlacklist(ChatroomUser user,
                               java.lang.String reason)
                        throws ChatException

  Add user to blacklist.

    `ChatException`

### removeFromBlacklist

    public void removeFromBlacklist(java.lang.String ip)

  Remove IP from blacklist.

### resetBlacklist

    public void resetBlacklist()

  Reset Blacklist.

### getBlacklist

    public Blacklist getBlacklist()

  Returns Blacklist.

### removeUser

    public void removeUser(java.lang.String name)
                    throws ChatException

  Removes an User.

    `ChatException`

### addMsg

    public void addMsg(Msg msg)
                throws ChatException

  Adds message to Chat. null content message is discarded.

    `ChatException`

### getChat

    public java.util.Vector getChat()

  Returns the whole Chat.

### getChat

    public java.util.Vector getChat(java.lang.String username)

  Returns the Chat content for an user only.
  We filter on "To" field. (To==username OR To==ALL OR To=BROADCAST OR myPrivateMsg)
  myPrivateMsg = (Type==PRIVATE AND From==username)

### getUsers

    public java.util.Hashtable getUsers()

  Returns Users.

### clear

    public void clear()

  Clear chatroom content.

### performLogout

    public void performLogout(ChatroomUser user)

  Remove user from chatroom. His HttpSession timed out or invalidated.

  Specified by:
    `performLogout` in interface `LogListener`

### performLogin

    public void performLogin(ChatroomUser user)

  LogListener dummy implementation.

  Specified by:
    `performLogin` in interface `LogListener`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD