public class Sessions
extends java.lang.Object
Worker
threads, therefore
methods must guarantee the access to the list.Modifier and Type | Field and Description |
---|---|
protected java.util.HashMap<java.lang.String,Session> |
sessions
Contains a list that is used to save client's sessions.
|
Constructor and Description |
---|
Sessions()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Session session)
Adds the specified element to the end of the list.
|
boolean |
belongs(java.lang.String cid1,
java.lang.String cid2)
Checks whether the
cid1 and cid2 channel
identifiers belongs to the same session. |
void |
clear()
Remove all elements from the clients list
|
void |
closeChannel(java.lang.String cid)
Closes all channels that belongs to the same sessions, so the session
is closed but not removed.
|
boolean |
contains(java.lang.String cid)
Returns true if the clients list contains the specified element.
|
Session |
get(java.lang.String cid)
Returns the first element of the queue if it isn't empty, otherwise null.
|
java.util.Set<java.lang.String> |
getKeySet() |
boolean |
isEmpty()
Checks if there is a empty list of sessions.
|
void |
list(java.io.PrintStream out)
Prints this ClientSessions out to the specified output stream.
|
void |
remove(java.lang.String cid)
Removes the element that it is identifier by a channel identifier.
|
int |
size()
Returns the number of sessions.
|
java.lang.String |
toString()
For debugging purpose.
|
protected java.util.HashMap<java.lang.String,Session> sessions
The key
of the HasMap is a session identifier and the
value
is a session.
public void add(Session session)
session
- element to be appended to this list.public void remove(java.lang.String cid)
cid
- the channel identifier.public Session get(java.lang.String cid)
public boolean contains(java.lang.String cid)
cid
- public boolean belongs(java.lang.String cid1, java.lang.String cid2)
cid1
and cid2
channel
identifiers belongs to the same session.cid1
- a channel identifier.cid2
- a channel identifier.true
if both channel identifiers belong to the same
session. Otherwise, returns false
.public void closeChannel(java.lang.String cid)
cid
- the unique channel identifier.public int size()
public boolean isEmpty()
true
if there is not any sessions. Otherwise,
returns false
.public java.util.Set<java.lang.String> getKeySet()
public void clear()
public java.lang.String toString()
toString
in class java.lang.Object
public void list(java.io.PrintStream out)
out
- an output stream.
CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Group on Interactive Coding of Images (GICI) (contact)