org.vrspace.server
Class Client

java.lang.Object
  extended byjava.util.Observable
      extended byorg.vrspace.server.VRObject
          extended byorg.vrspace.server.DBObject
              extended byorg.vrspace.server.PublicDBObject
                  extended byorg.vrspace.server.OwnedDBObject
                      extended byorg.vrspace.server.Client
All Implemented Interfaces:
java.lang.Cloneable, HasTransform, java.util.Observer, Owned, Owner
Direct Known Subclasses:
ClientGate, User

public class Client
extends OwnedDBObject
implements java.util.Observer, Owner, HasTransform

Generic Client class. Tracks visible objects, but forwards events to Dispatcher even if client sends events to invisible VRObjects.


Field Summary
 long _lastLogin
           
protected  AuthInfo authInfo
           
protected  Dispatcher dispatcher
           
 java.lang.String name
          client name (login)
protected  boolean online
           
protected  Transform pos
           
protected  Scene scene
           
protected  Session session
           
protected  int sessions
           
 long transform
           
 
Fields inherited from class org.vrspace.server.DBObject
db
 
Fields inherited from class org.vrspace.server.VRObject
db_id, primitiveMap, primitives
 
Constructor Summary
Client()
           
Client(Dispatcher d, AuthInfo a)
          Construct a new client.
 
Method Summary
 void addObject(VRObject obj)
          Add an object to the scene.
 void addObserver(java.util.Observer o)
          Called when another client observes this one instead of Observable.addObserver()
 void addOwned(Owned o)
          Interface Owner - own o
 void deleteObserver(java.util.Observer o)
          called when this another client stops observing this, overrides Observable.deleteObserver()
protected  void destroy()
          Clean up.
 java.lang.ClassLoader getClassLoader()
          Returns ClassLoader of this thread
 Dispatcher getDispatcher()
          Returns Dispatcher
protected  ObjectFilter getFilter(Request r, java.lang.String filter)
           
 java.lang.String getName()
          Get client name
 Transform getPos()
          This returns client's Transform.
 ObservableProperties getProperties()
          Convenicence method
 java.lang.String getProperty(java.lang.String key)
          Convenicence method
 Scene getScene()
          Returns this client's scene
 Session getSession()
          this shouldn't be public...
 Transform getTransform()
           
 long getTransformID()
           
protected  void init()
          This is called by the dispatcher after login.
 void invalidRequest(Request r)
          Called from Dispatcher if request() sent an invalid request
 boolean isOnline()
          Is client on-line?
 boolean isOwner(Owned o)
          Interface Owner - owns o?
 boolean owns(VRObject o)
          Convenience method.
 void quit()
          Logout.
 void removeAll()
          Removes all objects from the scene
 void removeObject(VRObject obj)
          Remove object obj from the scene
 void removeOwned(Owned o)
          Interface Owner - do not own o
 void request(Request r)
          A new client request.
 void sendResponse(Request r, java.lang.String response)
          Sends the response back to the client
TODO:
Include more information to the response (originating request id)
 void set__password(Request r, java.lang.String passwd)
          Changes password
 void set__sceneRange(Request r, java.lang.String range)
          Set Scene range
 void set__sceneSize(Request r, java.lang.String size)
          Set Scene size
 void set_addFilter(Request r, java.lang.String filter)
          adds class filter
usage: my addFilter org.vrspace.server.filter.ClassFilter VrmlFile removes all VrmlFile instances from the scene. Default package name for filters is org.vrspace.server.filter Tries to call constructor with following parameters:
- String
- Request
- none (Class.newInstance)
 void set_removeFilter(Request r, java.lang.String filter)
          removes filter
 void setProperty(java.lang.String name, java.lang.String value)
          Convenicence method
 void setTransform(Transform t)
           
protected  void setValue(Request r)
          This method forwards events to other intances on the net Request is already processed, validated etc.
 void update(java.util.Observable o, java.lang.Object req)
          Method update is called from VRObject class notifyObservers() Notifies the client an object in the scene has changed
NOTE: o may be null.
 void updateAuthInfo(Client c)
          Updates AuthInfo.
 void updateAuthInfo(Dispatcher dispatcher, Client client)
          A hack until objects are given a reference to their dispatcher on startup.
 void updateOwnership(Owned o, java.lang.Object obj)
          Called when :
- this client receives an object, scene updates - another ownership change occur
 void updateScene()
          update the scene
 void updateScene(boolean forceUpdate)
          update the scene
 void updateScene(double x, double y, double z, boolean forceUpdate)
          Update the scene with those coordinates, should be called with scene changes
 
Methods inherited from class org.vrspace.server.OwnedDBObject
addOwner, isOwned, notifyOwners, ownershipRequired, processEvent, removeOwner, sendEvent
 
Methods inherited from class org.vrspace.server.DBObject
delete, get, put, put
 
Methods inherited from class org.vrspace.server.VRObject
arrayToString, canRead, canWrite, clone, equals, fieldToText, fromString, fromText, getClassName, getField, getFields, getId, getID, getMemebers, hasField, hasMethod, isNew, newInstance, sendResponse, setField, setField, setField, setFields, setFields, stringToArray, toString, toText, toText, toText
 
Methods inherited from class java.util.Observable
clearChanged, countObservers, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dispatcher

protected Dispatcher dispatcher

authInfo

protected AuthInfo authInfo

session

protected Session session

scene

protected Scene scene

transform

public long transform

_lastLogin

public long _lastLogin

sessions

protected int sessions

name

public java.lang.String name
client name (login)


pos

protected Transform pos

online

protected boolean online
Constructor Detail

Client

public Client()

Client

public Client(Dispatcher d,
              AuthInfo a)
Construct a new client. Each client type should do init here, i.e. User should build up the scene.

Method Detail

getName

public java.lang.String getName()
Get client name


getDispatcher

public Dispatcher getDispatcher()
Returns Dispatcher


addObserver

public void addObserver(java.util.Observer o)
Called when another client observes this one instead of Observable.addObserver()


deleteObserver

public void deleteObserver(java.util.Observer o)
called when this another client stops observing this, overrides Observable.deleteObserver()


update

public void update(java.util.Observable o,
                   java.lang.Object req)
Method update is called from VRObject class notifyObservers() Notifies the client an object in the scene has changed
NOTE: o may be null. This implies one object changes itself. However this is not a rule; various sub- and superclasses may use self as well as null for the argument - check for null as well for this.equals( o )! This implementation sends request as-is to the client if o is either null or self.

Specified by:
update in interface java.util.Observer

sendResponse

public void sendResponse(Request r,
                         java.lang.String response)
Sends the response back to the client
TODO:
Include more information to the response (originating request id)


quit

public void quit()
Logout. First clears the scene.


request

public void request(Request r)
A new client request. Network layer constructs new request and calls this method. Asks the Dispatcher to change a VRObject's variable value. If Dispatcher throws an exception, it's propagated to the client.


invalidRequest

public void invalidRequest(Request r)
Called from Dispatcher if request() sent an invalid request


addObject

public void addObject(VRObject obj)
               throws java.lang.IllegalAccessException
Add an object to the scene. Called from ProxyDispatcher, Scene, VRObject or Command classes... Creates new Requests and sends them to the uderlying session

Throws:
java.lang.IllegalAccessException

removeObject

public void removeObject(VRObject obj)
                  throws java.lang.IllegalAccessException
Remove object obj from the scene

Throws:
java.lang.IllegalAccessException

removeAll

public void removeAll()
Removes all objects from the scene


destroy

protected void destroy()
Clean up.


init

protected void init()
This is called by the dispatcher after login. Session and all other fields are set prior to init.
This implementation does nothing.


updateScene

public void updateScene()
                 throws VRObjectException
update the scene

Throws:
VRObjectException

updateScene

public void updateScene(boolean forceUpdate)
                 throws VRObjectException
update the scene

Throws:
VRObjectException

updateScene

public void updateScene(double x,
                        double y,
                        double z,
                        boolean forceUpdate)
                 throws VRObjectException
Update the scene with those coordinates, should be called with scene changes

Throws:
VRObjectException

setValue

protected void setValue(Request r)
This method forwards events to other intances on the net Request is already processed, validated etc. Here, just determine what should be forwareded.
NOTE: this implementation does nothing

Overrides:
setValue in class PublicDBObject

addOwned

public void addOwned(Owned o)
Interface Owner - own o

Specified by:
addOwned in interface Owner

removeOwned

public void removeOwned(Owned o)
Interface Owner - do not own o

Specified by:
removeOwned in interface Owner

isOwner

public boolean isOwner(Owned o)
Interface Owner - owns o?

Specified by:
isOwner in interface Owner

owns

public boolean owns(VRObject o)
Convenience method. Calls isOwner( Owned ) if o instanceof Owned, else returns false.


updateOwnership

public void updateOwnership(Owned o,
                            java.lang.Object obj)
Called when :
- this client receives an object, scene updates - another ownership change occur

Specified by:
updateOwnership in interface Owner

isOnline

public boolean isOnline()
Is client on-line?


getPos

public Transform getPos()
This returns client's Transform. Needed to calculate distances.


set_addFilter

public void set_addFilter(Request r,
                          java.lang.String filter)
                   throws java.lang.Exception
adds class filter
usage: my addFilter org.vrspace.server.filter.ClassFilter VrmlFile removes all VrmlFile instances from the scene. Default package name for filters is org.vrspace.server.filter Tries to call constructor with following parameters:
- String
- Request
- none (Class.newInstance)

Throws:
java.lang.Exception
See Also:
Scene, ClassFilter

getFilter

protected ObjectFilter getFilter(Request r,
                                 java.lang.String filter)
                          throws java.lang.Exception
Throws:
java.lang.Exception

set_removeFilter

public void set_removeFilter(Request r,
                             java.lang.String filter)
                      throws java.lang.Exception
removes filter

Throws:
java.lang.Exception
See Also:
Scene, #addFilter

getScene

public Scene getScene()
Returns this client's scene


updateAuthInfo

public void updateAuthInfo(Client c)
                    throws java.lang.Exception
Updates AuthInfo. Use when db_id or class changes.

Throws:
java.lang.Exception

updateAuthInfo

public void updateAuthInfo(Dispatcher dispatcher,
                           Client client)
                    throws java.lang.Exception
A hack until objects are given a reference to their dispatcher on startup.

Throws:
java.lang.Exception

set__password

public void set__password(Request r,
                          java.lang.String passwd)
Changes password


getProperties

public ObservableProperties getProperties()
Convenicence method

See Also:
Server

getProperty

public java.lang.String getProperty(java.lang.String key)
Convenicence method

See Also:
Server

setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)
Convenicence method

See Also:
Server

getClassLoader

public java.lang.ClassLoader getClassLoader()
Returns ClassLoader of this thread


set__sceneSize

public void set__sceneSize(Request r,
                           java.lang.String size)
Set Scene size

See Also:
Scene

set__sceneRange

public void set__sceneRange(Request r,
                            java.lang.String range)
Set Scene range

See Also:
Secene

getSession

public Session getSession()
this shouldn't be public...


getTransform

public Transform getTransform()
Specified by:
getTransform in interface HasTransform

setTransform

public void setTransform(Transform t)
Specified by:
setTransform in interface HasTransform

getTransformID

public long getTransformID()
Specified by:
getTransformID in interface HasTransform