From 961f3ffdfe0e552b987c62aabc2113d5583ee474 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Thu, 2 Mar 2006 03:07:01 +0000 Subject: [PATCH] More bits and hackery (and a hand-generated TimeBaseMarshaller, so that I can get fully logged in). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3904 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/presents/client/Client.as | 9 +++-- .../presents/client/GotTimeBaseListener.as | 7 ++++ .../threerings/presents/client/TestClient.as | 9 +++++ .../presents/client/TimeBaseService.as | 39 +++++++++++++++++++ .../presents/data/GotTimeBaseMarshaller.as | 32 +++++++++++++++ .../presents/data/InvocationMarshaller.as | 2 + .../presents/data/ListenerMarshaller.as | 2 +- .../presents/data/TimeBaseMarshaller.as | 26 +++++++++++++ 8 files changed, 122 insertions(+), 4 deletions(-) create mode 100644 src/as/com/threerings/presents/client/GotTimeBaseListener.as create mode 100644 src/as/com/threerings/presents/client/TimeBaseService.as create mode 100644 src/as/com/threerings/presents/data/GotTimeBaseMarshaller.as create mode 100644 src/as/com/threerings/presents/data/TimeBaseMarshaller.as diff --git a/src/as/com/threerings/presents/client/Client.as b/src/as/com/threerings/presents/client/Client.as index 4b5540022..dfb985a73 100644 --- a/src/as/com/threerings/presents/client/Client.as +++ b/src/as/com/threerings/presents/client/Client.as @@ -94,11 +94,14 @@ public class Client extends EventDispatcher public function getService (clazz :Class) :InvocationService { - if (_bstrap == null) { - return null; + if (_bstrap != null) { + for each (var service :InvocationService in _bstrap.services) { + if (service is clazz) { + return service; + } + } } - // TODO return null; } diff --git a/src/as/com/threerings/presents/client/GotTimeBaseListener.as b/src/as/com/threerings/presents/client/GotTimeBaseListener.as new file mode 100644 index 000000000..523ac6e24 --- /dev/null +++ b/src/as/com/threerings/presents/client/GotTimeBaseListener.as @@ -0,0 +1,7 @@ +package com.threerings.presents.client { + +public interface GotTimeBaseListener extends InvocationListener +{ + function gotTimeOid (timeOid :int) :void; +} +} diff --git a/src/as/com/threerings/presents/client/TestClient.as b/src/as/com/threerings/presents/client/TestClient.as index 4e8dc8eeb..ec8eef9e2 100644 --- a/src/as/com/threerings/presents/client/TestClient.as +++ b/src/as/com/threerings/presents/client/TestClient.as @@ -1,6 +1,7 @@ package com.threerings.presents.client { import com.threerings.util.Name; +import com.threerings.presents.data.TimeBaseMarshaller; import com.threerings.presents.net.UsernamePasswordCreds; public class TestClient extends Client @@ -11,5 +12,13 @@ public class TestClient extends Client setServer("tasman.sea.earth.threerings.net", DEFAULT_SERVER_PORT); logon(); } + + + // If a class isn't used anywhere, it won't get added to the .swf. + // Here, I hack. + public function fuckingCompiler () :void + { + var i :int = TimeBaseMarshaller.GET_TIME_OID; + } } } diff --git a/src/as/com/threerings/presents/client/TimeBaseService.as b/src/as/com/threerings/presents/client/TimeBaseService.as new file mode 100644 index 000000000..0e4d87fcc --- /dev/null +++ b/src/as/com/threerings/presents/client/TimeBaseService.as @@ -0,0 +1,39 @@ +// +// $Id: TimeBaseService.java 3099 2004-08-27 02:21:06Z mdb $ +// +// Narya library - tools for developing networked games +// Copyright (C) 2002-2004 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.presents.client { + +import com.threerings.presents.client.Client; +import com.threerings.presents.client.InvocationService; + +/** + * Provides a means by which to obtain access to a time base object which + * can be used to convert delta times into absolute times. + */ +public interface TimeBaseService extends InvocationService +{ + /** + * Requests the oid of the specified time base object be fetched. + */ + function getTimeOid ( + client :Client, timeBase :String, listener :GotTimeBaseListener) :void; +} +} diff --git a/src/as/com/threerings/presents/data/GotTimeBaseMarshaller.as b/src/as/com/threerings/presents/data/GotTimeBaseMarshaller.as new file mode 100644 index 000000000..390f83a32 --- /dev/null +++ b/src/as/com/threerings/presents/data/GotTimeBaseMarshaller.as @@ -0,0 +1,32 @@ +package com.threerings.presents.data { + +import com.threerings.presents.client.GotTimeBaseListener; + +import com.threerings.presents.dobj.InvocationResponseEvent; + +// TODO: this will be autogenerated +public class GotTimeBaseMarshaller extends ListenerMarshaller + implements GotTimeBaseListener +{ + public static const GOT_TIME_OID :int = 1; + + public function gotTimeOid (arg1 :int) :void + { + omgr.postEvent(new InvocationResponseEvent( + callerOid, requestId, GOT_TIME_OID, [ arg1 ])); + } + + public override function dispatchResponse (methodId :int, args :Array) :void + { + switch (methodId) { + case GOT_TIME_OID: + (listener as GotTimeBaseListener).gotTimeOid(args[0] as int); + return; + + default: + super.dispatchResponse(methodId, args); + return; + } + } +} +} diff --git a/src/as/com/threerings/presents/data/InvocationMarshaller.as b/src/as/com/threerings/presents/data/InvocationMarshaller.as index 9347fbf84..a4e1cda4e 100644 --- a/src/as/com/threerings/presents/data/InvocationMarshaller.as +++ b/src/as/com/threerings/presents/data/InvocationMarshaller.as @@ -23,6 +23,8 @@ package com.threerings.presents.data { import com.threerings.util.ClassUtil; +import com.threerings.io.ObjectInputStream; +import com.threerings.io.ObjectOutputStream; import com.threerings.io.Streamable; import com.threerings.presents.Log; diff --git a/src/as/com/threerings/presents/data/ListenerMarshaller.as b/src/as/com/threerings/presents/data/ListenerMarshaller.as index 0809dc85d..d621889d2 100644 --- a/src/as/com/threerings/presents/data/ListenerMarshaller.as +++ b/src/as/com/threerings/presents/data/ListenerMarshaller.as @@ -17,7 +17,7 @@ public class ListenerMarshaller implements Streamable, InvocationListener { /** The method id used to dispatch a requestFailed response. */ - public const REQUEST_FAILED_RSPID :int = 0; + public static const REQUEST_FAILED_RSPID :int = 0; /** The oid of the invocation service requester. */ public var callerOid :int; diff --git a/src/as/com/threerings/presents/data/TimeBaseMarshaller.as b/src/as/com/threerings/presents/data/TimeBaseMarshaller.as new file mode 100644 index 000000000..27db39746 --- /dev/null +++ b/src/as/com/threerings/presents/data/TimeBaseMarshaller.as @@ -0,0 +1,26 @@ +package com.threerings.presents.data { + +import com.threerings.presents.client.Client; +import com.threerings.presents.client.GotTimeBaseListener; +import com.threerings.presents.client.TimeBaseService; + +import com.threerings.presents.data.InvocationMarshaller; + +import com.threerings.presents.dobj.InvocationResponseEvent; + +// TODO +// This will be auto-generated soon from the service definition +public class TimeBaseMarshaller extends InvocationMarshaller + implements TimeBaseService +{ + public static const GET_TIME_OID :int = 1; + + public function getTimeOid ( + arg1 :Client, arg2 :String, arg3 :GotTimeBaseListener) :void + { + var listener3 :GotTimeBaseMarshaller = new GotTimeBaseMarshaller(); + listener3.listener = arg3; + sendRequest(arg1, GET_TIME_OID, [arg2, listener3]); + } +} +}