|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.elkoserver.server.context.BasicObject
org.elkoserver.server.context.Context
public class Context
A Context is a place for interaction between connected users. It
is one of the three basic object types (along with User and Item).
| Field Summary |
|---|
| Fields inherited from class org.elkoserver.server.context.BasicObject |
|---|
VIS_CONTAINER, VIS_NONE, VIS_PERSONAL, VIS_PUBLIC |
| Method Summary | |
|---|---|
int |
baseCapacity()
Obtain the number of users who may enter (a clone of) this context before another clone must be created. |
void |
closeGate(String reason)
Close this context's gate, blocking new users from entering. |
Context |
context()
Obtain the context this object is associated with. |
JSONLiteral |
encode(EncodeControl control)
Encode this context for transmission or persistence. |
void |
exit(Deliverer from)
Handle the 'exit' verb. |
void |
forceClose()
Close this context, even if it has been retained by one or more calls to the retain() method, and even if there are still users in it
(this means kicking those users off). |
boolean |
gateIsClosed()
Test if this context's gate is closed. |
BasicObject |
get(String ref)
Look up an object in this context's namespace. |
Object |
getStaticObject(String ref)
Look up one of this server's static objects. |
boolean |
isContainer()
Test if this object is a container. |
boolean |
isRestricted()
Test if this context is restricted, that is, whether it is closed to entry without an internally requested reservation. |
boolean |
isSemiPrivate()
Test if this context is semi-private. |
String |
loadedFromRef()
Obtain the ref of the context descriptor from which this context was loaded. |
int |
maxCapacity()
Obtain the number of users who may enter before no more are allowed in. |
Deliverer |
neighbors(Deliverer exclude)
Obtain a Deliverer that will deliver to all of a user's neighbors in this context. |
void |
openGate()
Open this context's gate, allowing new users in if the context is not full. |
void |
registerContextShutdownWatcher(ContextShutdownWatcher watcher)
Register a callback to be invoked when the context is shut down. |
void |
registerUserWatcher(UserWatcher watcher)
Register a callback to be invoked when a user enters or exits the context. |
void |
release()
Release an earlier call to retain(). |
void |
retain()
Keep this context open even if all users exit (normally a context will be shut down automatically after the last user leaves). |
void |
scheduleContextEvent(long millis,
Runnable thunk)
Schedule a timer event associated with this context. |
void |
send(JSONLiteral message)
Send a message to everyone in this context. |
void |
sendObjectDescription(Deliverer to,
Referenceable maker)
Transmit a description of this context as a series of 'make' messages, such that the receiver will be able to construct a local presence of it. |
void |
sendToNeighbors(Deliverer exclude,
JSONLiteral message)
Send a message to everyone in this context save one. |
static Deliverer |
toList(List<BasicObject> toList)
Obtain a Deliverer that will deliver to an arbitrary list of users. |
static Deliverer |
toListExcluding(List<BasicObject> toList,
Deliverer exclude)
Obtain a Deliverer that will deliver to an arbitrary list of users except for one distinguished user. |
String |
toString()
Obtain a printable string representation of this context. |
Trace |
trace()
Obtain a trace object for logging. |
User |
user()
Obtain the user this object is currently contained by. |
int |
userCount()
Get the number of users in this context. |
Iterator<User> |
userIterator()
Obtain an iterator over the users currently in this context. |
| Methods inherited from class org.elkoserver.server.context.BasicObject |
|---|
baseRef, checkpoint, checkpoint, container, contents, contextor, createItem, findActualTarget, getMod, handleMessage, holder, isClone, isEphemeral, markAsChanged, markAsDeleted, markAsEphemeral, name, noteCodependent, objectIsComplete, position, ref, sendToClones, setName, setPosition, setVisibility, visibleTo |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public int baseCapacity()
maxCapacity() is not exceeded), but users who request entry to the
context by specifying its generic context ID (that is, its ID before
cloning) will be directed to a different clone.
public void closeGate(String reason)
reason - String describing why this is being done.public void forceClose()
retain() method, and even if there are still users in it
(this means kicking those users off).
public boolean gateIsClosed()
public BasicObject get(String ref)
ref - Reference string denoting the object desired.
public Object getStaticObject(String ref)
ref - Reference string denoting the object of interest.
public boolean isSemiPrivate()
public boolean isRestricted()
public String loadedFromRef()
public int maxCapacity()
public void openGate()
public void registerContextShutdownWatcher(ContextShutdownWatcher watcher)
watcher - An object to notify when the context is shut down.public void registerUserWatcher(UserWatcher watcher)
watcher - An object to notify when a user arrives.public void release()
retain(). When release() has
been called the same number of times as retain() has been, the
context is free to shut down when empty. If the context is already
empty, it will be shut down immediately. Calls to this method in excess
of the number of calls to retain() will be ignored.
public void retain()
retain() must be matched by a corresponding call to release() in order for the context to be permitted to close normally
(though it can still be closed by called forceClose()).
public void scheduleContextEvent(long millis,
Runnable thunk)
millis - How long to wait until timing out.thunk - Thunk to be run when the timeout happens.
public void sendObjectDescription(Deliverer to,
Referenceable maker)
sendObjectDescription in class BasicObjectto - Where to send the description.maker - Maker object to address the message(s) to.
public void sendToNeighbors(Deliverer exclude,
JSONLiteral message)
exclude - Who to exclude from the send operation.message - The message to send.public Deliverer neighbors(Deliverer exclude)
exclude - Who to exclude from the send operation.
public static Deliverer toList(List<BasicObject> toList)
toList - List of users to deliver to
public static Deliverer toListExcluding(List<BasicObject> toList,
Deliverer exclude)
toList - List of users to deliver toexclude - The one to exclude
public String toString()
toString in class Objectpublic Trace trace()
public int userCount()
public Iterator<User> userIterator()
@JSONMethod
public void exit(Deliverer from)
throws MessageHandlerException
MessageHandlerExceptionpublic Context context()
context in class BasicObjectpublic boolean isContainer()
isContainer in class BasicObjectpublic User user()
user in class BasicObjectpublic void send(JSONLiteral message)
send in interface Deliverermessage - The message to send.public JSONLiteral encode(EncodeControl control)
encode in interface Encodablecontrol - Encode control determining what flavor of encoding
should be done.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||