Files
narya/src/java/com/threerings/crowd/server/CrowdClient.java
T
Michael Bayne bf77cb1520 Moved location services implementation into LocationManager so that
LocationProvider can be an interface like its brothers and sisters.

Modified the place registry to create PlaceManager instances using the injector
so that we can inject dependencies into managers. Also modified the custom
classloader functionality so that it can/will circumvent this process
entirely. It's not possible to inject using a custom classloader and one
certainly would not want to do so.

Unfortunately this means we can't inject some basic managers into PlaceManager
because it needs to work for games loaded into a sandboxed classloader, but the
big win is that in everything other than GameManager and PlaceManager, we can
inject to our heart's content.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5168 542714f4-19e9-0310-aa3c-eee0fc999fb1
2008-06-08 17:18:26 +00:00

90 lines
3.1 KiB
Java

//
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.crowd.server;
import com.threerings.presents.dobj.AccessController;
import com.threerings.presents.server.PresentsClient;
import com.threerings.crowd.chat.server.SpeakUtil;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.server.CrowdServer;
/**
* The crowd client extends the presents client with crowd-specific client handling.
*/
public class CrowdClient extends PresentsClient
{
// documentation inherited
protected void sessionConnectionClosed ()
{
super.sessionConnectionClosed();
if (_clobj != null) {
// note that the user is disconnected
BodyObject bobj = (BodyObject)_clobj;
CrowdServer.bodyman.updateOccupantStatus(bobj, bobj.location, OccupantInfo.DISCONNECTED);
}
}
// documentation inherited
protected void sessionWillResume ()
{
super.sessionWillResume();
// note that the user's active once more
BodyObject bobj = (BodyObject)_clobj;
CrowdServer.bodyman.updateOccupantStatus(bobj, bobj.location, OccupantInfo.ACTIVE);
}
// documentation inherited
protected void sessionDidEnd ()
{
super.sessionDidEnd();
BodyObject body = (BodyObject)_clobj;
// clear out our location so that anyone listening will know that we've left
clearLocation(body);
// reset our status in case this object remains around until they start their next session
// (which could happen very soon)
CrowdServer.bodyman.updateOccupantStatus(body, null, OccupantInfo.ACTIVE);
// clear our chat history
if (body != null) {
SpeakUtil.clearHistory(body.getVisibleName());
}
}
/**
* When the user ends their session, this method is called to clear out any location they might
* occupy. The default implementation takes care of standard crowd location occupancy, but
* users of other services may which to override this method and clear the user out of a scene,
* zone or other location-derived occupancy.
*/
protected void clearLocation (BodyObject bobj)
{
CrowdServer.locman.leaveOccupiedPlace(bobj);
}
}