├── .gitignore ├── docs ├── miso │ ├── fringebits.png │ ├── render_sort_diagram.dia │ ├── render_sort_diagram.png │ ├── scenegroup.xml │ └── scene.ps ├── presents │ └── images │ │ ├── dobject.dia │ │ └── dobject.png ├── whirled │ └── notes.txt ├── media │ ├── notes.txt │ └── design.txt ├── crowd │ └── notes.txt └── micasa │ └── design.txt ├── core └── src │ ├── main │ └── java │ │ └── com │ │ └── threerings │ │ ├── web │ │ ├── Base.gwt.xml │ │ └── gwt │ │ │ └── ServiceException.java │ │ ├── admin │ │ ├── web │ │ │ ├── Admin.gwt.xml │ │ │ └── gwt │ │ │ │ └── ConfigServiceAsync.java │ │ ├── Log.java │ │ ├── data │ │ │ ├── AdminCodes.java │ │ │ └── ConfigObject.java │ │ ├── server │ │ │ ├── persist │ │ │ │ └── ConfigDatum.java │ │ │ └── AdminProvider.java │ │ └── client │ │ │ └── AdminService.java │ │ ├── presents │ │ ├── server │ │ │ ├── InvocationProvider.java │ │ │ ├── SignalReceiver.java │ │ │ ├── ChainedAuthenticator.java │ │ │ ├── ClientLocal.java │ │ │ ├── RegistrationManager.java │ │ │ ├── ClientResolutionListener.java │ │ │ ├── PresentsAuthInvoker.java │ │ │ └── RegistrationProvider.java │ │ ├── data │ │ │ ├── Permission.java │ │ │ ├── TimeBaseCodes.java │ │ │ ├── InvocationObject.java │ │ │ └── PresentsConMgrStats.java │ │ ├── peer │ │ │ ├── server │ │ │ │ └── PeerClientResolver.java │ │ │ ├── data │ │ │ │ ├── PeerAuthName.java │ │ │ │ └── ClientInfo.java │ │ │ └── net │ │ │ │ ├── PeerBootstrapData.java │ │ │ │ └── PeerCreds.java │ │ ├── Log.java │ │ ├── net │ │ │ ├── TransmitDatagramsRequest.java │ │ │ ├── LogoffRequest.java │ │ │ ├── CompoundDownstreamMessage.java │ │ │ ├── UpdateThrottleMessage.java │ │ │ ├── CompoundUpstreamMessage.java │ │ │ ├── ThrottleUpdatedMessage.java │ │ │ ├── DownstreamMessage.java │ │ │ ├── AuthResponseData.java │ │ │ ├── SecureRequest.java │ │ │ ├── BootstrapData.java │ │ │ ├── UnsubscribeResponse.java │ │ │ └── FailureResponse.java │ │ ├── dobj │ │ │ ├── NoSuchObjectException.java │ │ │ ├── ChangeListener.java │ │ │ ├── SimpleEntry.java │ │ │ ├── MessageListener.java │ │ │ ├── ObjectDeathListener.java │ │ │ ├── AccessController.java │ │ │ ├── ElementUpdateListener.java │ │ │ ├── AttributeChangeListener.java │ │ │ ├── NamedElementUpdateListener.java │ │ │ ├── EventListener.java │ │ │ ├── ProxySubscriber.java │ │ │ ├── OidListListener.java │ │ │ └── ServerMessageEvent.java │ │ ├── client │ │ │ ├── PresentsPrefs.java │ │ │ ├── RegistrationService.java │ │ │ ├── ClientObjectInputStream.java │ │ │ ├── LoggingListener.java │ │ │ └── TimeBaseService.java │ │ ├── annotation │ │ │ ├── AuthInvoker.java │ │ │ ├── AnyThread.java │ │ │ ├── PeerInvoker.java │ │ │ ├── MainInvoker.java │ │ │ ├── TransportHint.java │ │ │ ├── EventQueue.java │ │ │ ├── EventThread.java │ │ │ └── BlockingThread.java │ │ └── util │ │ │ ├── ConfirmAdapter.java │ │ │ └── ResultListenerList.java │ │ ├── crowd │ │ ├── client │ │ │ ├── MoveVetoedException.java │ │ │ ├── MoveFailedException.java │ │ │ ├── BodyService.java │ │ │ ├── LocationReceiver.java │ │ │ ├── OccupantAdapter.java │ │ │ ├── OccupantObserver.java │ │ │ └── LocationAdapter.java │ │ ├── Log.java │ │ ├── chat │ │ │ ├── data │ │ │ │ ├── KeepNoHistory.java │ │ │ │ ├── TellFeedbackMessage.java │ │ │ │ ├── ChatChannel.java │ │ │ │ └── UserSystemMessage.java │ │ │ ├── client │ │ │ │ ├── ChannelSpeakService.java │ │ │ │ ├── ChatFilter.java │ │ │ │ ├── ChatDisplay.java │ │ │ │ └── SpeakService.java │ │ │ └── server │ │ │ │ ├── SpeakProvider.java │ │ │ │ └── ChannelSpeakProvider.java │ │ ├── data │ │ │ ├── CrowdCodes.java │ │ │ ├── Place.java │ │ │ └── LocationCodes.java │ │ ├── peer │ │ │ ├── data │ │ │ │ └── CrowdClientInfo.java │ │ │ └── client │ │ │ │ └── CrowdPeerService.java │ │ └── server │ │ │ ├── OccupantOp.java │ │ │ ├── BodyLocal.java │ │ │ ├── BodyProvider.java │ │ │ ├── CrowdClientResolver.java │ │ │ ├── LocationSender.java │ │ │ └── LocationProvider.java │ │ ├── util │ │ ├── Equalable.java │ │ ├── Hashable.java │ │ └── StreamableTuple.java │ │ ├── bureau │ │ ├── data │ │ │ ├── BureauAuthName.java │ │ │ ├── BureauCodes.java │ │ │ ├── BureauClientObject.java │ │ │ └── BureauCredentials.java │ │ ├── Log.java │ │ ├── server │ │ │ ├── BureauSession.java │ │ │ └── BureauClientResolver.java │ │ ├── util │ │ │ └── BureauContext.java │ │ └── client │ │ │ └── Agent.java │ │ ├── NaryaLog.java │ │ └── io │ │ ├── NotStreamable.java │ │ ├── Intern.java │ │ ├── ClassMapping.java │ │ └── SimpleStreamableObject.java │ └── test │ ├── resources │ ├── config │ │ └── presents │ │ │ └── server.properties │ └── i18n │ │ └── messages.properties │ └── java │ └── com │ └── threerings │ ├── presents │ ├── data │ │ └── TestClientObject.java │ ├── client │ │ └── TestReceiver.java │ ├── server │ │ ├── PresentsTestBase.java │ │ ├── TestSender.java │ │ └── OMgrIntervalTest.java │ └── peer │ │ └── server │ │ └── TestPeerManager.java │ └── crowd │ ├── client │ └── JabberController.java │ ├── data │ └── JabberConfig.java │ └── server │ └── JabberServer.java ├── cpplib └── src │ ├── presents │ ├── ClassMapping.h │ ├── platform │ │ └── NSLog.mm │ ├── InvocationDecoder.cpp │ ├── io │ │ ├── InputStream.h │ │ ├── OutputStream.h │ │ ├── FramingOutputStream.h │ │ ├── FramedInputStream.h │ │ └── FramingOutputStream.cpp │ ├── streamers │ │ ├── StringStreamer.h │ │ ├── StringStreamer.cpp │ │ └── StreamableStreamer.h │ ├── PresentsError.h │ ├── DisconnectReason.h │ ├── Streamable.h │ ├── net │ │ ├── Credentials.cpp │ │ ├── UpstreamMessage.cpp │ │ ├── DownstreamMessage.cpp │ │ ├── PingRequest.cpp │ │ ├── Credentials.h │ │ ├── AuthResponseData.cpp │ │ ├── PingRequest.h │ │ ├── UpstreamMessage.h │ │ ├── DownstreamMessage.h │ │ ├── AuthResponseData.h │ │ ├── ObjectResponse.cpp │ │ ├── AuthResponse.cpp │ │ ├── EventNotification.cpp │ │ ├── PongResponse.h │ │ ├── ForwardEventRequest.cpp │ │ ├── PongResponse.cpp │ │ ├── ObjectResponse.h │ │ ├── BootstrapNotification.cpp │ │ ├── EventNotification.h │ │ ├── ForwardEventRequest.h │ │ ├── AuthResponse.h │ │ ├── UsernamePasswordCreds.h │ │ ├── BootstrapNotification.h │ │ ├── UsernamePasswordCreds.cpp │ │ ├── BootstrapData.h │ │ ├── BootstrapData.cpp │ │ ├── AuthRequest.h │ │ └── AuthRequest.cpp │ ├── data │ │ ├── PermissionPolicy.cpp │ │ ├── InvocationMarshaller.cpp │ │ ├── PermissionPolicy.h │ │ ├── InvocationMarshaller.h │ │ ├── ClientObject.cpp │ │ └── ClientObject.h │ ├── dobj │ │ ├── DEvent.cpp │ │ ├── DObject.cpp │ │ ├── EntryEvent.cpp │ │ ├── NamedEvent.cpp │ │ ├── DEvent.h │ │ ├── DObject.h │ │ ├── EntryEvent.h │ │ ├── DSet.h │ │ ├── NamedEvent.h │ │ ├── EntryAddedEvent.cpp │ │ ├── EntryRemovedEvent.cpp │ │ ├── EntryUpdatedEvent.cpp │ │ ├── EntryAddedEvent.h │ │ ├── EntryRemovedEvent.h │ │ ├── EntryUpdatedEvent.h │ │ ├── DSet.cpp │ │ ├── InvocationRequestEvent.h │ │ ├── InvocationNotificationEvent.h │ │ ├── InvocationRequestEvent.cpp │ │ └── InvocationNotificationEvent.cpp │ ├── ArrayMask.h │ ├── Util.cpp │ ├── SocketStream.h │ ├── box │ │ ├── BoxedInt.cpp │ │ ├── BoxedByte.cpp │ │ ├── BoxedFloat.cpp │ │ ├── BoxedShort.cpp │ │ ├── BoxedDouble.cpp │ │ ├── BoxedBoolean.cpp │ │ ├── BoxedInt.h │ │ ├── BoxedByte.h │ │ ├── BoxedFloat.h │ │ ├── BoxedShort.h │ │ ├── BoxedBoolean.h │ │ └── BoxedDouble.h │ ├── InvocationDecoder.h │ ├── client │ │ ├── Registration.cpp │ │ └── Registration.h │ ├── Util.h │ ├── ArrayMask.cpp │ └── ObjectInputStream.h │ └── util │ ├── Name.cpp │ └── Name.h ├── tools └── src │ └── main │ ├── resources │ └── com │ │ └── threerings │ │ └── presents │ │ ├── tools │ │ ├── dobject_name.tmpl │ │ ├── receiver_as.tmpl │ │ ├── cpp │ │ │ ├── receiver_h.mustache │ │ │ ├── decoder_h.mustache │ │ │ ├── streamable_h.mustache │ │ │ ├── streamable_cpp.mustache │ │ │ ├── marshaller_cpp.mustache │ │ │ ├── decoder_cpp.mustache │ │ │ └── marshaller_h.mustache │ │ ├── service_as.tmpl │ │ ├── service_listener_as.tmpl │ │ ├── provider.tmpl │ │ ├── dobject_oidlist.tmpl │ │ ├── sender.tmpl │ │ └── marshaller_listener_as.tmpl │ │ └── tools.properties │ └── java │ └── com │ └── threerings │ └── presents │ └── tools │ ├── KeyPairGen.java │ └── StreamableClassRequirements.java ├── etc └── SOURCE_HEADER ├── aslib └── src │ ├── test │ └── thane │ │ └── BureauTestClient.as │ └── main │ └── as │ └── com │ └── threerings │ ├── presents │ ├── data │ │ └── Permission.as │ └── net │ │ ├── LogoffRequest.as │ │ └── Credentials_HasLanguage.as │ ├── util │ ├── ResultListener.as │ └── Boxed.as │ └── crowd │ └── client │ └── MoveVetoedError.as └── .travis.yml /.gitignore: -------------------------------------------------------------------------------- 1 | */target/ 2 | -------------------------------------------------------------------------------- /docs/miso/fringebits.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/narya/HEAD/docs/miso/fringebits.png -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/web/Base.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /docs/miso/render_sort_diagram.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/narya/HEAD/docs/miso/render_sort_diagram.dia -------------------------------------------------------------------------------- /docs/miso/render_sort_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/narya/HEAD/docs/miso/render_sort_diagram.png -------------------------------------------------------------------------------- /docs/presents/images/dobject.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/narya/HEAD/docs/presents/images/dobject.dia -------------------------------------------------------------------------------- /docs/presents/images/dobject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/narya/HEAD/docs/presents/images/dobject.png -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/admin/web/Admin.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /cpplib/src/presents/ClassMapping.h: -------------------------------------------------------------------------------- 1 | // 2 | // $Id$ 3 | 4 | #pragma once 5 | 6 | struct Streamer; 7 | 8 | struct ClassMapping 9 | { 10 | int16 code; 11 | Streamer* streamer; 12 | }; 13 | -------------------------------------------------------------------------------- /cpplib/src/presents/platform/NSLog.mm: -------------------------------------------------------------------------------- 1 | #include "presents/Util.h" 2 | #undef interface 3 | 4 | #include 5 | 6 | void presents::log(const char* msg) 7 | { 8 | NSLog(@"%s", msg); 9 | } 10 | -------------------------------------------------------------------------------- /tools/src/main/resources/com/threerings/presents/tools/dobject_name.tmpl: -------------------------------------------------------------------------------- 1 | /** The field name of the {{field}} field. */ 2 | {{generated}} 3 | public static final String {{capfield}} = "{{field}}"; 4 | -------------------------------------------------------------------------------- /cpplib/src/presents/InvocationDecoder.cpp: -------------------------------------------------------------------------------- 1 | #include "stable.h" 2 | #include "InvocationDecoder.h" 3 | 4 | using namespace presents; 5 | 6 | InvocationDecoder::InvocationDecoder(utf8 rcode) : 7 | receiverCode(rcode) 8 | { 9 | } -------------------------------------------------------------------------------- /etc/SOURCE_HEADER: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | -------------------------------------------------------------------------------- /cpplib/src/presents/io/InputStream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace presents { 4 | class InputStream { 5 | public: 6 | virtual ~InputStream() {}; 7 | virtual size_t read(void* pData, size_t bytesToRead) = 0; 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /aslib/src/test/thane/BureauTestClient.as: -------------------------------------------------------------------------------- 1 | package { 2 | 3 | import avmplus.System; 4 | import com.threerings.bureau.client.TestClient; 5 | 6 | 7 | public class BureauTestClient 8 | { 9 | TestClient.main(System.argv); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cpplib/src/presents/io/OutputStream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace presents { 4 | class OutputStream { 5 | public: 6 | virtual ~OutputStream() {}; 7 | virtual size_t write(const uint8* pData, size_t bytesToWrite) = 0; 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /cpplib/src/presents/streamers/StringStreamer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Streamer.h" 4 | 5 | class StringStreamer : public Streamer 6 | { 7 | public: 8 | Shared createObject (ObjectInputStream& in); 9 | void writeObject (const Shared& object, ObjectOutputStream& out); 10 | }; 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: java 4 | 5 | jdk: 6 | - openjdk7 7 | - oraclejdk8 8 | 9 | branches: 10 | only: 11 | - master 12 | 13 | cache: 14 | directories: 15 | - '$HOME/.m2/repository' 16 | 17 | script: 18 | - mvn -B test 19 | - rm -rf $HOME/.m2/repository/com/threerings/narya* 20 | -------------------------------------------------------------------------------- /cpplib/src/presents/PresentsError.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace presents 4 | { 5 | class PresentsError : public std::runtime_error 6 | { 7 | public: 8 | PresentsError(const std::string& message) : std::runtime_error(message) 9 | {} 10 | 11 | virtual ~PresentsError() throw() 12 | {} 13 | }; 14 | } -------------------------------------------------------------------------------- /core/src/test/resources/config/presents/server.properties: -------------------------------------------------------------------------------- 1 | # 2 | # $Id$ 3 | # 4 | # Configuration for the Presents test server 5 | 6 | # These invocation service providers will be registered with the 7 | # invocation manager during the server init process 8 | providers = \ 9 | test = com.threerings.presents.server.TestProvider 10 | -------------------------------------------------------------------------------- /cpplib/src/presents/DisconnectReason.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace presents 4 | { enum DisconnectReason { 5 | NETWORK_DISCONNECT, 6 | SERVER_DISCONNECT, 7 | CLIENT_CLOSED, 8 | SERVER_UNREACHABLE, 9 | UNKNOWN 10 | }; 11 | 12 | typedef boost::signal DisconnectEvent; 13 | } -------------------------------------------------------------------------------- /cpplib/src/presents/Streamable.h: -------------------------------------------------------------------------------- 1 | // 2 | // $Id$ 3 | 4 | #pragma once 5 | 6 | class ObjectOutputStream; 7 | class ObjectInputStream; 8 | 9 | struct Streamable 10 | { 11 | virtual void writeObject (ObjectOutputStream& out) const = 0; 12 | virtual void readObject (ObjectInputStream& in) = 0; 13 | virtual const utf8& getJavaClassName () const = 0; 14 | }; 15 | 16 | -------------------------------------------------------------------------------- /cpplib/src/util/Name.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "Name.h" 3 | 4 | using namespace util; 5 | 6 | DEFINE_STREAMABLE("com.threerings.util.Name", Name); 7 | 8 | void Name::readObject (ObjectInputStream& in) 9 | { 10 | name = in.readField< utf8 >(); 11 | } 12 | 13 | void Name::writeObject (ObjectOutputStream& out) const 14 | { 15 | out.writeField(name); 16 | } 17 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/Credentials.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "Credentials.h" 3 | 4 | using namespace presents::net; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.net.Credentials", Credentials); 7 | 8 | void Credentials::readObject (ObjectInputStream& /*in*/) 9 | { 10 | } 11 | 12 | void Credentials::writeObject (ObjectOutputStream& /*out*/) const 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/resources/i18n/messages.properties: -------------------------------------------------------------------------------- 1 | # 2 | # $Id$ 3 | # 4 | # Test localization properties file 5 | 6 | m.foo = Foo arg one is '{0}' and two is '{1}'. 7 | m.biff = Biff arg one is '{0}' and two is '{1}'. 8 | m.meta = Meta arg one is '{0}' and two is '{1}'. 9 | 10 | m.sheep = Don't suffix me 11 | m.sheep.0 = No sheep 12 | m.sheep.1 = One sheep 13 | m.sheep.n = {0} sheeps 14 | 15 | m.coord = {0}x{1} 16 | -------------------------------------------------------------------------------- /cpplib/src/presents/data/PermissionPolicy.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "PermissionPolicy.h" 3 | 4 | using namespace presents::data; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.data.PermissionPolicy", PermissionPolicy); 7 | 8 | void PermissionPolicy::readObject (ObjectInputStream& /*in*/) 9 | { 10 | } 11 | 12 | void PermissionPolicy::writeObject (ObjectOutputStream& /*out*/) const 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/DEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "DEvent.h" 3 | 4 | using namespace presents::dobj; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.dobj.DEvent", DEvent); 7 | 8 | void DEvent::readObject (ObjectInputStream& in) 9 | { 10 | toid = int32(in.readInt()); 11 | } 12 | 13 | void DEvent::writeObject (ObjectOutputStream& out) const 14 | { 15 | out.writeInt(toid); 16 | } 17 | -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/DObject.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "DObject.h" 3 | 4 | using namespace presents::dobj; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.dobj.DObject", DObject); 7 | 8 | void DObject::readObject (ObjectInputStream& in) 9 | { 10 | oid = int32(in.readInt()); 11 | } 12 | 13 | void DObject::writeObject (ObjectOutputStream& out) const 14 | { 15 | out.writeInt(oid); 16 | } 17 | -------------------------------------------------------------------------------- /cpplib/src/presents/ArrayMask.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ObjectInputStream.h" 4 | #include "ObjectOutputStream.h" 5 | 6 | class ArrayMask 7 | { 8 | public: 9 | ArrayMask (int length); 10 | ArrayMask (ObjectInputStream& in); 11 | ~ArrayMask(); 12 | void set (int index); 13 | bool isSet (int index); 14 | void writeTo (ObjectOutputStream& out); 15 | protected: 16 | uint8* _mask; 17 | int _length; 18 | }; 19 | -------------------------------------------------------------------------------- /tools/src/main/resources/com/threerings/presents/tools/receiver_as.tmpl: -------------------------------------------------------------------------------- 1 | package {{package}} { 2 | 3 | {{#importGroups}} 4 | {{#this}} 5 | import {{this}}; 6 | {{/this}} 7 | 8 | {{/importGroups}} 9 | public interface {{name}}Receiver extends InvocationReceiver 10 | { 11 | {{#methods}} 12 | {{^-first}} 13 | 14 | {{/-first}} 15 | // from Java interface {{name}}Receiver 16 | function {{method.name}} ({{getASArgList}}) :void; 17 | {{/methods}} 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/server/InvocationProvider.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.server; 7 | 8 | /** 9 | * All invocation providers must implement this placeholder interface. 10 | */ 11 | public interface InvocationProvider 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /cpplib/src/presents/Util.cpp: -------------------------------------------------------------------------------- 1 | #include "Util.h" 2 | 3 | void presents::internal::log(const char* format, ...) 4 | { 5 | va_list argumentList; 6 | va_start(argumentList, format); 7 | 8 | char buffer[1024]; 9 | #ifdef PRESENTS_COMPILER_MSVC 10 | if (_vsnprintf(buffer, 1024, format, argumentList) > 0) { 11 | #else 12 | if (vsprintf(buffer, format, argumentList) > 0) { 13 | #endif 14 | presents::log(buffer); 15 | } 16 | 17 | va_end(argumentList); 18 | } -------------------------------------------------------------------------------- /core/src/test/java/com/threerings/presents/data/TestClientObject.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.data; 7 | 8 | /** 9 | * Used to test using a custom client object in invocation services. 10 | */ 11 | public class TestClientObject extends ClientObject 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/EntryEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "EntryEvent.h" 3 | 4 | using namespace presents::dobj; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.dobj.EntryEvent", EntryEvent); 7 | 8 | void EntryEvent::readObject (ObjectInputStream& in) 9 | { 10 | presents::dobj::NamedEvent::readObject(in); 11 | } 12 | 13 | void EntryEvent::writeObject (ObjectOutputStream& out) const 14 | { 15 | presents::dobj::NamedEvent::writeObject(out); 16 | } 17 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/UpstreamMessage.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "UpstreamMessage.h" 3 | 4 | using namespace presents::net; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.net.UpstreamMessage", UpstreamMessage); 7 | 8 | void UpstreamMessage::readObject (ObjectInputStream& in) 9 | { 10 | messageId = int16(in.readShort()); 11 | } 12 | 13 | void UpstreamMessage::writeObject (ObjectOutputStream& out) const 14 | { 15 | out.writeShort(messageId); 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/client/MoveVetoedException.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.client; 7 | 8 | /** 9 | * An exception that indicates that a LocationObserver vetoed our move request. 10 | */ 11 | public class MoveVetoedException extends Exception 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/data/Permission.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.data; 7 | 8 | /** 9 | * A value class used by {@link ClientObject#checkAccess(Permission)} to do fine-grained access 10 | * control. 11 | */ 12 | public class Permission 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/util/Equalable.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.util; 7 | 8 | /** 9 | * This exists solely for classes with generated ActionScript counterparts that need to implement 10 | * the Equalable.as interface 11 | */ 12 | public interface Equalable 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/util/Hashable.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.util; 7 | 8 | /** 9 | * This exists solely for classes with generated ActionScript counterparts that need to implement 10 | * the Hashable.as interface 11 | */ 12 | public interface Hashable 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /cpplib/src/presents/io/FramingOutputStream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "OutputStream.h" 4 | 5 | namespace presents { 6 | 7 | class FramingOutputStream : public OutputStream { 8 | public: 9 | FramingOutputStream (OutputStream* base); 10 | 11 | // Returns bytes written 12 | virtual size_t write (const uint8* pData, size_t bytesToWrite); 13 | void writeFrame (); 14 | 15 | protected: 16 | OutputStream* _base; 17 | std::vector _frameBuffer; 18 | }; 19 | } -------------------------------------------------------------------------------- /cpplib/src/presents/net/DownstreamMessage.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "DownstreamMessage.h" 3 | 4 | using namespace presents::net; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.net.DownstreamMessage", DownstreamMessage); 7 | 8 | void DownstreamMessage::readObject (ObjectInputStream& in) 9 | { 10 | messageId = int16(in.readShort()); 11 | } 12 | 13 | void DownstreamMessage::writeObject (ObjectOutputStream& out) const 14 | { 15 | out.writeShort(messageId); 16 | } 17 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/PingRequest.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "PingRequest.h" 3 | 4 | using namespace presents::net; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.net.PingRequest", PingRequest); 7 | 8 | void PingRequest::readObject (ObjectInputStream& in) 9 | { 10 | presents::net::UpstreamMessage::readObject(in); 11 | } 12 | 13 | void PingRequest::writeObject (ObjectOutputStream& out) const 14 | { 15 | presents::net::UpstreamMessage::writeObject(out); 16 | } 17 | -------------------------------------------------------------------------------- /tools/src/main/resources/com/threerings/presents/tools/cpp/receiver_h.mustache: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "{{decoderName}}.h" 4 | {{#includes}} 5 | #include "{{this}}" 6 | {{/includes}} 7 | 8 | {{#namespaces}}namespace {{this}} { {{/namespaces}} 9 | 10 | 11 | class {{receiverName}} { 12 | public: 13 | typedef {{decoderName}} Decoder; 14 | 15 | {{#methods}} 16 | virtual void {{methodName}} ({{arguments}}) = 0; 17 | {{/methods}} 18 | }; 19 | 20 | {{#namespaces}} 21 | }{{/namespaces}} 22 | -------------------------------------------------------------------------------- /cpplib/src/presents/io/FramedInputStream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "InputStream.h" 4 | 5 | namespace presents { 6 | 7 | class FramedInputStream : public InputStream 8 | { 9 | public: 10 | FramedInputStream (InputStream* base); 11 | virtual size_t read(void* pData, size_t bytesToRead); 12 | bool readFrame (); 13 | protected: 14 | int32 _length; 15 | InputStream* _base; 16 | boost::scoped_array _readBuffer; 17 | int32 _fillPosition, _readPosition, _readBufferLength; 18 | }; 19 | } -------------------------------------------------------------------------------- /cpplib/src/presents/streamers/StringStreamer.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "StringStreamer.h" 3 | 4 | #include 5 | 6 | #include "../ObjectInputStream.h" 7 | #include "../ObjectOutputStream.h" 8 | 9 | Shared StringStreamer::createObject (ObjectInputStream& in) 10 | { 11 | return Shared(new utf8(in.readUTF())); 12 | } 13 | 14 | void StringStreamer::writeObject (const Shared& object, ObjectOutputStream& out) 15 | { 16 | out.writeUTF(*(boost::static_pointer_cast(object))); 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/server/SignalReceiver.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.server; 7 | 8 | /** 9 | * If injected into a presents server, listens for a USR2 Unix signal captured by 10 | * {@link AbstractSignalHandler}. 11 | */ 12 | public interface SignalReceiver 13 | { 14 | void received(); 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/peer/server/PeerClientResolver.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.peer.server; 7 | 8 | import com.threerings.presents.server.ClientResolver; 9 | 10 | /** 11 | * Handles the resolution of peer server client data. 12 | */ 13 | public class PeerClientResolver extends ClientResolver 14 | { 15 | } 16 | -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/NamedEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "NamedEvent.h" 3 | 4 | using namespace presents::dobj; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.dobj.NamedEvent", NamedEvent); 7 | 8 | void NamedEvent::readObject (ObjectInputStream& in) 9 | { 10 | presents::dobj::DEvent::readObject(in); 11 | name = in.readField< utf8 >(); 12 | } 13 | 14 | void NamedEvent::writeObject (ObjectOutputStream& out) const 15 | { 16 | presents::dobj::DEvent::writeObject(out); 17 | out.writeField(name); 18 | } 19 | -------------------------------------------------------------------------------- /tools/src/main/resources/com/threerings/presents/tools/service_as.tmpl: -------------------------------------------------------------------------------- 1 | package {{package}} { 2 | 3 | {{#importGroups}} 4 | {{#this}} 5 | import {{this}}; 6 | {{/this}} 7 | 8 | {{/importGroups}} 9 | /** 10 | * An ActionScript version of the Java {{name}}Service interface. 11 | */ 12 | public interface {{name}}Service extends InvocationService 13 | { 14 | {{#methods}} 15 | {{^-first}} 16 | 17 | {{/-first}} 18 | // from Java interface {{name}}Service 19 | function {{method.name}} ({{getASArgList}}) :void; 20 | {{/methods}} 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /cpplib/src/presents/SocketStream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "DisconnectReason.h" 4 | #include "io/InputStream.h" 5 | #include "io/OutputStream.h" 6 | 7 | namespace presents { 8 | class SocketStream : public InputStream, public OutputStream 9 | { 10 | public: 11 | virtual ~SocketStream() {}; 12 | virtual void close () = 0; 13 | virtual void update (float dt) = 0; 14 | virtual connection_t onDisconnect (const DisconnectEvent::slot_type& slot) = 0; 15 | }; 16 | 17 | SocketStream* createSocketStream (const char* hostname, int port); 18 | } -------------------------------------------------------------------------------- /cpplib/src/util/Name.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/Streamable.h" 9 | 10 | namespace util { 11 | 12 | class Name : public Streamable { 13 | public: 14 | DECLARE_STREAMABLE(); 15 | 16 | Shared name; 17 | 18 | virtual void readObject(ObjectInputStream& in); 19 | virtual void writeObject(ObjectOutputStream& out) const; 20 | }; 21 | 22 | } -------------------------------------------------------------------------------- /cpplib/src/presents/box/BoxedInt.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "BoxedInt.h" 3 | #include "presents/ObjectInputStream.h" 4 | #include "presents/ObjectOutputStream.h" 5 | // Generated by running python boxer.py in this directory 6 | 7 | using namespace presents::box; 8 | 9 | DEFINE_STREAMABLE("java.lang.Integer", BoxedInt); 10 | 11 | void BoxedInt::readObject (ObjectInputStream& in) 12 | { 13 | value = in.readInt(); 14 | } 15 | 16 | void BoxedInt::writeObject (ObjectOutputStream& out) const 17 | { 18 | out.writeInt(value); 19 | } 20 | -------------------------------------------------------------------------------- /cpplib/src/presents/box/BoxedByte.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "BoxedByte.h" 3 | #include "presents/ObjectInputStream.h" 4 | #include "presents/ObjectOutputStream.h" 5 | // Generated by running python boxer.py in this directory 6 | 7 | using namespace presents::box; 8 | 9 | DEFINE_STREAMABLE("java.lang.Byte", BoxedByte); 10 | 11 | void BoxedByte::readObject (ObjectInputStream& in) 12 | { 13 | value = in.readByte(); 14 | } 15 | 16 | void BoxedByte::writeObject (ObjectOutputStream& out) const 17 | { 18 | out.writeByte(value); 19 | } 20 | -------------------------------------------------------------------------------- /cpplib/src/presents/InvocationDecoder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Streamable.h" 4 | 5 | namespace presents 6 | { 7 | class InvocationDecoder { 8 | public: 9 | const utf8 receiverCode; 10 | InvocationDecoder(utf8 receiverCode); 11 | virtual void dispatchNotification(int8 methodId, const std::vector< Shared >& args) = 0; 12 | 13 | private: 14 | // not implemented 15 | InvocationDecoder (const InvocationDecoder&); 16 | InvocationDecoder& operator= (const InvocationDecoder&); 17 | }; 18 | } -------------------------------------------------------------------------------- /cpplib/src/presents/box/BoxedFloat.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "BoxedFloat.h" 3 | #include "presents/ObjectInputStream.h" 4 | #include "presents/ObjectOutputStream.h" 5 | // Generated by running python boxer.py in this directory 6 | 7 | using namespace presents::box; 8 | 9 | DEFINE_STREAMABLE("java.lang.Float", BoxedFloat); 10 | 11 | void BoxedFloat::readObject (ObjectInputStream& in) 12 | { 13 | value = in.readFloat(); 14 | } 15 | 16 | void BoxedFloat::writeObject (ObjectOutputStream& out) const 17 | { 18 | out.writeFloat(value); 19 | } 20 | -------------------------------------------------------------------------------- /cpplib/src/presents/box/BoxedShort.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "BoxedShort.h" 3 | #include "presents/ObjectInputStream.h" 4 | #include "presents/ObjectOutputStream.h" 5 | // Generated by running python boxer.py in this directory 6 | 7 | using namespace presents::box; 8 | 9 | DEFINE_STREAMABLE("java.lang.Short", BoxedShort); 10 | 11 | void BoxedShort::readObject (ObjectInputStream& in) 12 | { 13 | value = in.readShort(); 14 | } 15 | 16 | void BoxedShort::writeObject (ObjectOutputStream& out) const 17 | { 18 | out.writeShort(value); 19 | } 20 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/Credentials.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/Streamable.h" 9 | 10 | namespace presents { namespace net { 11 | 12 | class Credentials : public Streamable { 13 | public: 14 | DECLARE_STREAMABLE(); 15 | 16 | 17 | virtual void readObject(ObjectInputStream& in); 18 | virtual void writeObject(ObjectOutputStream& out) const; 19 | }; 20 | 21 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/box/BoxedDouble.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "BoxedDouble.h" 3 | #include "presents/ObjectInputStream.h" 4 | #include "presents/ObjectOutputStream.h" 5 | // Generated by running python boxer.py in this directory 6 | 7 | using namespace presents::box; 8 | 9 | DEFINE_STREAMABLE("java.lang.Double", BoxedDouble); 10 | 11 | void BoxedDouble::readObject (ObjectInputStream& in) 12 | { 13 | value = in.readDouble(); 14 | } 15 | 16 | void BoxedDouble::writeObject (ObjectOutputStream& out) const 17 | { 18 | out.writeDouble(value); 19 | } 20 | -------------------------------------------------------------------------------- /cpplib/src/presents/data/InvocationMarshaller.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "InvocationMarshaller.h" 3 | 4 | using namespace presents::data; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.data.InvocationMarshaller", InvocationMarshaller); 7 | 8 | void InvocationMarshaller::readObject (ObjectInputStream& in) 9 | { 10 | invOid = int32(in.readInt()); 11 | invCode = int32(in.readInt()); 12 | } 13 | 14 | void InvocationMarshaller::writeObject (ObjectOutputStream& out) const 15 | { 16 | out.writeInt(invOid); 17 | out.writeInt(invCode); 18 | } 19 | -------------------------------------------------------------------------------- /cpplib/src/presents/data/PermissionPolicy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/Streamable.h" 9 | 10 | namespace presents { namespace data { 11 | 12 | class PermissionPolicy : public Streamable { 13 | public: 14 | DECLARE_STREAMABLE(); 15 | 16 | 17 | virtual void readObject(ObjectInputStream& in); 18 | virtual void writeObject(ObjectOutputStream& out) const; 19 | }; 20 | 21 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/box/BoxedBoolean.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "BoxedBoolean.h" 3 | #include "presents/ObjectInputStream.h" 4 | #include "presents/ObjectOutputStream.h" 5 | // Generated by running python boxer.py in this directory 6 | 7 | using namespace presents::box; 8 | 9 | DEFINE_STREAMABLE("java.lang.Boolean", BoxedBoolean); 10 | 11 | void BoxedBoolean::readObject (ObjectInputStream& in) 12 | { 13 | value = in.readBoolean(); 14 | } 15 | 16 | void BoxedBoolean::writeObject (ObjectOutputStream& out) const 17 | { 18 | out.writeBoolean(value); 19 | } 20 | -------------------------------------------------------------------------------- /cpplib/src/presents/client/Registration.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "Registration.h" 3 | 4 | using namespace presents::client; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.client.InvocationReceiver$Registration", Registration); 7 | 8 | void Registration::readObject (ObjectInputStream& in) 9 | { 10 | receiverCode = in.readField< utf8 >(); 11 | receiverId = int16(in.readShort()); 12 | } 13 | 14 | void Registration::writeObject (ObjectOutputStream& out) const 15 | { 16 | out.writeField(receiverCode); 17 | out.writeShort(receiverId); 18 | } 19 | -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/DEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/Streamable.h" 9 | 10 | namespace presents { namespace dobj { 11 | 12 | class DEvent : public Streamable { 13 | public: 14 | DECLARE_STREAMABLE(); 15 | 16 | int32 toid; 17 | 18 | virtual void readObject(ObjectInputStream& in); 19 | virtual void writeObject(ObjectOutputStream& out) const; 20 | }; 21 | 22 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/DObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/Streamable.h" 9 | 10 | namespace presents { namespace dobj { 11 | 12 | class DObject : public Streamable { 13 | public: 14 | DECLARE_STREAMABLE(); 15 | 16 | int32 oid; 17 | 18 | virtual void readObject(ObjectInputStream& in); 19 | virtual void writeObject(ObjectOutputStream& out) const; 20 | }; 21 | 22 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/net/AuthResponseData.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "AuthResponseData.h" 3 | 4 | using namespace presents::net; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.net.AuthResponseData", AuthResponseData); 7 | 8 | void AuthResponseData::readObject (ObjectInputStream& in) 9 | { 10 | presents::dobj::DObject::readObject(in); 11 | code = in.readField< utf8 >(); 12 | } 13 | 14 | void AuthResponseData::writeObject (ObjectOutputStream& out) const 15 | { 16 | presents::dobj::DObject::writeObject(out); 17 | out.writeField(code); 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/bureau/data/BureauAuthName.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.bureau.data; 7 | 8 | import com.threerings.util.Name; 9 | 10 | /** 11 | * Represents an authenticated bureau client. 12 | */ 13 | public class BureauAuthName extends Name 14 | { 15 | public BureauAuthName (String bureauId) 16 | { 17 | super(bureauId); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/client/MoveFailedException.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.client; 7 | 8 | /** 9 | * An exception that indicates that the server did not allow us to move. 10 | */ 11 | public class MoveFailedException extends Exception 12 | { 13 | public MoveFailedException (String message) 14 | { 15 | super(message); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/EntryEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/dobj/NamedEvent.h" 9 | 10 | namespace presents { namespace dobj { 11 | 12 | class EntryEvent : public presents::dobj::NamedEvent { 13 | public: 14 | DECLARE_STREAMABLE(); 15 | 16 | 17 | virtual void readObject(ObjectInputStream& in); 18 | virtual void writeObject(ObjectOutputStream& out) const; 19 | }; 20 | 21 | }} -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/peer/data/PeerAuthName.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.peer.data; 7 | 8 | import com.threerings.util.Name; 9 | 10 | /** 11 | * Represents an authenticated peer client. 12 | */ 13 | public class PeerAuthName extends Name 14 | { 15 | public PeerAuthName (String nodeName) 16 | { 17 | super(nodeName); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/com/threerings/presents/client/TestReceiver.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.client; 7 | 8 | /** 9 | * A test of the invocation notification services. 10 | */ 11 | public interface TestReceiver extends InvocationReceiver 12 | { 13 | /** 14 | * Dispatches a test notification. 15 | */ 16 | public void receivedTest (int one, String two); 17 | } 18 | -------------------------------------------------------------------------------- /docs/miso/scenegroup.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Town Square 11 | South 12 | 13 | 14 | 15 | 16 | Harbour 17 | West 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/NaryaLog.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings; 7 | 8 | import com.samskivert.util.Logger; 9 | 10 | /** 11 | * Contains a reference to the log object used by this project. 12 | */ 13 | public class NaryaLog 14 | { 15 | /** We dispatch our log messages through this logger. */ 16 | public static Logger log = Logger.getLogger("com.threerings.narya"); 17 | } 18 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/PingRequest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/net/UpstreamMessage.h" 9 | 10 | namespace presents { namespace net { 11 | 12 | class PingRequest : public presents::net::UpstreamMessage { 13 | public: 14 | DECLARE_STREAMABLE(); 15 | 16 | 17 | virtual void readObject(ObjectInputStream& in); 18 | virtual void writeObject(ObjectOutputStream& out) const; 19 | }; 20 | 21 | }} -------------------------------------------------------------------------------- /tools/src/main/resources/com/threerings/presents/tools.properties: -------------------------------------------------------------------------------- 1 | gendobj=com.threerings.presents.tools.GenDObjectTask 2 | genservice=com.threerings.presents.tools.GenServiceTask 3 | genreceiver=com.threerings.presents.tools.GenReceiverTask 4 | instream=com.threerings.presents.tools.InstrumentStreamableTask 5 | genascriptstreamable=com.threerings.presents.tools.GenActionScriptStreamableTask 6 | gencppservice=com.threerings.presents.tools.cpp.GenCPPServiceTask 7 | gencppstreamable=com.threerings.presents.tools.cpp.GenCPPStreamableTask 8 | gencppreceiver=com.threerings.presents.tools.cpp.GenCPPReceiverTask 9 | -------------------------------------------------------------------------------- /tools/src/main/resources/com/threerings/presents/tools/cpp/decoder_h.mustache: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/InvocationDecoder.h" 4 | 5 | {{#namespaces}} 6 | namespace {{this}} { {{/namespaces}} 7 | 8 | class {{receiverName}}; 9 | 10 | class {{decoderName}} : public presents::InvocationDecoder { 11 | public: 12 | {{decoderName}}(Shared<{{receiverName}}> receiver); 13 | void dispatchNotification(int8 methodId, const std::vector< Shared >& args); 14 | 15 | protected: 16 | Shared<{{receiverName}}> _receiver; 17 | }; 18 | 19 | {{#namespaces}} 20 | }{{/namespaces}} 21 | -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/DSet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | namespace presents { namespace dobj { 9 | 10 | class DSet : public Streamable { 11 | public: 12 | DECLARE_STREAMABLE(); 13 | 14 | Shared< std::vector< Shared > > entries; 15 | int32 size; 16 | 17 | virtual void readObject(ObjectInputStream& in); 18 | virtual void writeObject(ObjectOutputStream& out) const; 19 | }; 20 | 21 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/net/UpstreamMessage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/Streamable.h" 9 | 10 | namespace presents { namespace net { 11 | 12 | class UpstreamMessage : public Streamable { 13 | public: 14 | DECLARE_STREAMABLE(); 15 | 16 | int16 messageId; 17 | 18 | virtual void readObject(ObjectInputStream& in); 19 | virtual void writeObject(ObjectOutputStream& out) const; 20 | }; 21 | 22 | }} -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/Log.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd; 7 | 8 | import com.samskivert.util.Logger; 9 | 10 | /** 11 | * Contains a reference to the log object used by the Crowd services. 12 | */ 13 | public class Log 14 | { 15 | /** We dispatch our log messages through this logger. */ 16 | public static Logger log = Logger.getLogger("com.threerings.crowd"); 17 | } 18 | -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/NamedEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/dobj/DEvent.h" 9 | 10 | namespace presents { namespace dobj { 11 | 12 | class NamedEvent : public presents::dobj::DEvent { 13 | public: 14 | DECLARE_STREAMABLE(); 15 | 16 | Shared name; 17 | 18 | virtual void readObject(ObjectInputStream& in); 19 | virtual void writeObject(ObjectOutputStream& out) const; 20 | }; 21 | 22 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/net/DownstreamMessage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/Streamable.h" 9 | 10 | namespace presents { namespace net { 11 | 12 | class DownstreamMessage : public Streamable { 13 | public: 14 | DECLARE_STREAMABLE(); 15 | 16 | int16 messageId; 17 | 18 | virtual void readObject(ObjectInputStream& in); 19 | virtual void writeObject(ObjectOutputStream& out) const; 20 | }; 21 | 22 | }} -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/admin/Log.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.admin; 7 | 8 | import com.samskivert.util.Logger; 9 | 10 | /** 11 | * Contains a reference to the log object used by the Admin services. 12 | */ 13 | public class Log 14 | { 15 | /** We dispatch our log messages through this logger. */ 16 | public static Logger log = Logger.getLogger("com.threerings.narya.admin"); 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/bureau/Log.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.bureau; 7 | 8 | import com.samskivert.util.Logger; 9 | 10 | /** 11 | * Contains a reference to the log object used by the Bureau services. 12 | */ 13 | public class Log 14 | { 15 | /** We dispatch our log messages through this logger. */ 16 | public static Logger log = Logger.getLogger("com.threerings.bureau"); 17 | } 18 | -------------------------------------------------------------------------------- /docs/whirled/notes.txt: -------------------------------------------------------------------------------- 1 | Whirled Notes -*- outline -*- 2 | 3 | * 11/25/2002 4 | ** Scene tagging 5 | - Create a mechanism whereby scenes can be annotated with tags or somesuch 6 | which are available without resolving the scenes. 7 | 8 | * 12/20/2002 9 | ** Portal tagging 10 | - During the scene resolution process, tag portals that connect a scene to 11 | its neighbors in a named direction (north, east, south, west) as scene 12 | graph defining portals (and different from portals that link a scene to 13 | some internal sub-group like the entrance to an inn or a link to the set 14 | of rooms upstairs) 15 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/chat/data/KeepNoHistory.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.chat.data; 7 | 8 | import com.threerings.crowd.chat.server.SpeakUtil; 9 | import com.threerings.util.Name; 10 | 11 | /** 12 | * Marks a {@link Name} as disinterested in chat history such that {@link SpeakUtil} will keep no 13 | * messages sent to it. 14 | */ 15 | public interface KeepNoHistory 16 | { 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/Log.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents; 7 | 8 | import com.samskivert.util.Logger; 9 | 10 | /** 11 | * Contains a reference to the log object used by the Presents services. 12 | */ 13 | public class Log 14 | { 15 | /** We dispatch our log messages through this logger. */ 16 | public static Logger log = Logger.getLogger("com.threerings.presents"); 17 | } 18 | -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/EntryAddedEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "EntryAddedEvent.h" 3 | 4 | using namespace presents::dobj; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.dobj.EntryAddedEvent", EntryAddedEvent); 7 | 8 | void EntryAddedEvent::readObject (ObjectInputStream& in) 9 | { 10 | presents::dobj::EntryEvent::readObject(in); 11 | entry = boost::static_pointer_cast(in.readObject()); 12 | } 13 | 14 | void EntryAddedEvent::writeObject (ObjectOutputStream& out) const 15 | { 16 | presents::dobj::EntryEvent::writeObject(out); 17 | out.writeObject(entry); 18 | } 19 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/AuthResponseData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/dobj/DObject.h" 9 | 10 | namespace presents { namespace net { 11 | 12 | class AuthResponseData : public presents::dobj::DObject { 13 | public: 14 | DECLARE_STREAMABLE(); 15 | 16 | Shared code; 17 | 18 | virtual void readObject(ObjectInputStream& in); 19 | virtual void writeObject(ObjectOutputStream& out) const; 20 | }; 21 | 22 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/net/ObjectResponse.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "ObjectResponse.h" 3 | 4 | using namespace presents::net; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.net.ObjectResponse", ObjectResponse); 7 | 8 | void ObjectResponse::readObject (ObjectInputStream& in) 9 | { 10 | presents::net::DownstreamMessage::readObject(in); 11 | dobj = boost::static_pointer_cast(in.readObject()); 12 | } 13 | 14 | void ObjectResponse::writeObject (ObjectOutputStream& out) const 15 | { 16 | presents::net::DownstreamMessage::writeObject(out); 17 | out.writeObject(dobj); 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/data/TimeBaseCodes.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.data; 7 | 8 | /** 9 | * Codes and constants relating to the Presents time base services. 10 | */ 11 | public interface TimeBaseCodes extends InvocationCodes 12 | { 13 | /** An error response generated for GetTimeOid requests. */ 14 | public static final String NO_SUCH_TIME_BASE = "m.no_such_time_base"; 15 | } 16 | -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/EntryRemovedEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "EntryRemovedEvent.h" 3 | 4 | using namespace presents::dobj; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.dobj.EntryRemovedEvent", EntryRemovedEvent); 7 | 8 | void EntryRemovedEvent::readObject (ObjectInputStream& in) 9 | { 10 | presents::dobj::EntryEvent::readObject(in); 11 | key = boost::static_pointer_cast(in.readObject()); 12 | } 13 | 14 | void EntryRemovedEvent::writeObject (ObjectOutputStream& out) const 15 | { 16 | presents::dobj::EntryEvent::writeObject(out); 17 | out.writeObject(key); 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/data/CrowdCodes.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.data; 7 | 8 | import com.threerings.presents.data.InvocationCodes; 9 | 10 | /** 11 | * Codes and constants global to the Crowd services. 12 | */ 13 | public interface CrowdCodes extends InvocationCodes 14 | { 15 | /** Defines our invocation services group. */ 16 | public static final String CROWD_GROUP = "crowd"; 17 | } 18 | -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/EntryUpdatedEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "EntryUpdatedEvent.h" 3 | 4 | using namespace presents::dobj; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.dobj.EntryUpdatedEvent", EntryUpdatedEvent); 7 | 8 | void EntryUpdatedEvent::readObject (ObjectInputStream& in) 9 | { 10 | presents::dobj::EntryEvent::readObject(in); 11 | entry = boost::static_pointer_cast(in.readObject()); 12 | } 13 | 14 | void EntryUpdatedEvent::writeObject (ObjectOutputStream& out) const 15 | { 16 | presents::dobj::EntryEvent::writeObject(out); 17 | out.writeObject(entry); 18 | } 19 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/AuthResponse.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "AuthResponse.h" 3 | 4 | using namespace presents::net; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.net.AuthResponse", AuthResponse); 7 | 8 | void AuthResponse::readObject (ObjectInputStream& in) 9 | { 10 | presents::net::DownstreamMessage::readObject(in); 11 | data = boost::static_pointer_cast(in.readObject()); 12 | } 13 | 14 | void AuthResponse::writeObject (ObjectOutputStream& out) const 15 | { 16 | presents::net::DownstreamMessage::writeObject(out); 17 | out.writeObject(data); 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/admin/data/AdminCodes.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.admin.data; 7 | 8 | import com.threerings.presents.data.InvocationCodes; 9 | 10 | /** 11 | * Codes and consants relating to the admin services. 12 | */ 13 | public interface AdminCodes extends InvocationCodes 14 | { 15 | /** Defines our invocation service group. */ 16 | public static final String ADMIN_GROUP = "presents.admin"; 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/bureau/data/BureauCodes.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.bureau.data; 7 | 8 | import com.threerings.presents.data.InvocationCodes; 9 | 10 | /** 11 | * Codes and constants global to the Bureau services. 12 | */ 13 | public interface BureauCodes extends InvocationCodes 14 | { 15 | /** Defines our invocation services group. */ 16 | public static final String BUREAU_GROUP = "bureau"; 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/peer/net/PeerBootstrapData.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.peer.net; 7 | 8 | import com.threerings.presents.net.BootstrapData; 9 | 10 | /** 11 | * Extensd the standard bootstrap with some information needed by our peers. 12 | */ 13 | public class PeerBootstrapData extends BootstrapData 14 | { 15 | /** The id of this peer's node object. */ 16 | public int nodeOid; 17 | } 18 | -------------------------------------------------------------------------------- /cpplib/src/presents/client/Registration.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/Streamable.h" 9 | 10 | namespace presents { namespace client { 11 | 12 | class Registration : public Streamable { 13 | public: 14 | DECLARE_STREAMABLE(); 15 | 16 | Shared receiverCode; 17 | int16 receiverId; 18 | 19 | virtual void readObject(ObjectInputStream& in); 20 | virtual void writeObject(ObjectOutputStream& out) const; 21 | }; 22 | 23 | }} -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/net/TransmitDatagramsRequest.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.net; 7 | 8 | /** 9 | * Notifies the server that we would like it to send us datagrams. 10 | */ 11 | public class TransmitDatagramsRequest extends UpstreamMessage 12 | { 13 | @Override 14 | public String toString () 15 | { 16 | return "[type=TRANSMIT_DATAGRAMS, msgid=" + messageId + "]"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/EventNotification.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "EventNotification.h" 3 | 4 | using namespace presents::net; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.net.EventNotification", EventNotification); 7 | 8 | void EventNotification::readObject (ObjectInputStream& in) 9 | { 10 | presents::net::DownstreamMessage::readObject(in); 11 | event = boost::static_pointer_cast(in.readObject()); 12 | } 13 | 14 | void EventNotification::writeObject (ObjectOutputStream& out) const 15 | { 16 | presents::net::DownstreamMessage::writeObject(out); 17 | out.writeObject(event); 18 | } 19 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/PongResponse.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/net/DownstreamMessage.h" 9 | 10 | namespace presents { namespace net { 11 | 12 | class PongResponse : public presents::net::DownstreamMessage { 13 | public: 14 | DECLARE_STREAMABLE(); 15 | 16 | int64 packStamp; 17 | int32 processDelay; 18 | 19 | virtual void readObject(ObjectInputStream& in); 20 | virtual void writeObject(ObjectOutputStream& out) const; 21 | }; 22 | 23 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/net/ForwardEventRequest.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "ForwardEventRequest.h" 3 | 4 | using namespace presents::net; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.net.ForwardEventRequest", ForwardEventRequest); 7 | 8 | void ForwardEventRequest::readObject (ObjectInputStream& in) 9 | { 10 | presents::net::UpstreamMessage::readObject(in); 11 | event = boost::static_pointer_cast(in.readObject()); 12 | } 13 | 14 | void ForwardEventRequest::writeObject (ObjectOutputStream& out) const 15 | { 16 | presents::net::UpstreamMessage::writeObject(out); 17 | out.writeObject(event); 18 | } 19 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/PongResponse.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "PongResponse.h" 3 | 4 | using namespace presents::net; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.net.PongResponse", PongResponse); 7 | 8 | void PongResponse::readObject (ObjectInputStream& in) 9 | { 10 | presents::net::DownstreamMessage::readObject(in); 11 | packStamp = int64(in.readLong()); 12 | processDelay = int32(in.readInt()); 13 | } 14 | 15 | void PongResponse::writeObject (ObjectOutputStream& out) const 16 | { 17 | presents::net::DownstreamMessage::writeObject(out); 18 | out.writeLong(packStamp); 19 | out.writeInt(processDelay); 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/dobj/NoSuchObjectException.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.dobj; 7 | 8 | /** 9 | * A no such object exception is delivered when a subscriber requests 10 | * access to an object that does not exist. 11 | */ 12 | public class NoSuchObjectException extends ObjectAccessException 13 | { 14 | public NoSuchObjectException (int oid) 15 | { 16 | super("m.no_such_object\t" + oid); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/java/com/threerings/crowd/client/JabberController.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.client; 7 | 8 | import com.threerings.crowd.util.CrowdContext; 9 | 10 | /** 11 | * Handles the basic bits for our simple chat room. 12 | */ 13 | public class JabberController extends PlaceController 14 | { 15 | @Override 16 | protected PlaceView createPlaceView (CrowdContext ctx) 17 | { 18 | return new JabberPanel(ctx); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/EntryAddedEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/Streamable.h" 9 | #include "presents/dobj/EntryEvent.h" 10 | 11 | namespace presents { namespace dobj { 12 | 13 | class EntryAddedEvent : public presents::dobj::EntryEvent { 14 | public: 15 | DECLARE_STREAMABLE(); 16 | 17 | Shared entry; 18 | 19 | virtual void readObject(ObjectInputStream& in); 20 | virtual void writeObject(ObjectOutputStream& out) const; 21 | }; 22 | 23 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/EntryRemovedEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/Streamable.h" 9 | #include "presents/dobj/EntryEvent.h" 10 | 11 | namespace presents { namespace dobj { 12 | 13 | class EntryRemovedEvent : public presents::dobj::EntryEvent { 14 | public: 15 | DECLARE_STREAMABLE(); 16 | 17 | Shared key; 18 | 19 | virtual void readObject(ObjectInputStream& in); 20 | virtual void writeObject(ObjectOutputStream& out) const; 21 | }; 22 | 23 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/EntryUpdatedEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/Streamable.h" 9 | #include "presents/dobj/EntryEvent.h" 10 | 11 | namespace presents { namespace dobj { 12 | 13 | class EntryUpdatedEvent : public presents::dobj::EntryEvent { 14 | public: 15 | DECLARE_STREAMABLE(); 16 | 17 | Shared entry; 18 | 19 | virtual void readObject(ObjectInputStream& in); 20 | virtual void writeObject(ObjectOutputStream& out) const; 21 | }; 22 | 23 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/net/ObjectResponse.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/Streamable.h" 9 | #include "presents/net/DownstreamMessage.h" 10 | 11 | namespace presents { namespace net { 12 | 13 | class ObjectResponse : public presents::net::DownstreamMessage { 14 | public: 15 | DECLARE_STREAMABLE(); 16 | 17 | Shared dobj; 18 | 19 | virtual void readObject(ObjectInputStream& in); 20 | virtual void writeObject(ObjectOutputStream& out) const; 21 | }; 22 | 23 | }} -------------------------------------------------------------------------------- /docs/media/notes.txt: -------------------------------------------------------------------------------- 1 | Media Notes -*- mode: outline -*- 2 | 3 | * Old notes 4 | - Possibly modify TileSet to load images via image manager (move image 5 | provider up to media so that image manager can use tileset's image 6 | provider to load the image data) so that they can be cached (and more 7 | importantly, flushed from the cache). Presently tilesets are loaded into 8 | memory when tileset bundles are loaded and remain loaded forever. 9 | 10 | * 07/19/2002 11 | ** Virtual media panel 12 | - Make sure doLayout() is getting called soon enough to ensure that we 13 | don't improperly scroll the wrong thing if we're hijacked while in the 14 | middle of scrolling 15 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/peer/data/CrowdClientInfo.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.peer.data; 7 | 8 | import com.threerings.util.Name; 9 | 10 | import com.threerings.presents.peer.data.ClientInfo; 11 | 12 | /** 13 | * Extends the standard {@link ClientInfo} with Crowd bits. 14 | */ 15 | public class CrowdClientInfo extends ClientInfo 16 | { 17 | /** The client's visible name, which is used for chatting. */ 18 | public Name visibleName; 19 | } 20 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/BootstrapNotification.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "BootstrapNotification.h" 3 | 4 | using namespace presents::net; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.net.BootstrapNotification", BootstrapNotification); 7 | 8 | void BootstrapNotification::readObject (ObjectInputStream& in) 9 | { 10 | presents::net::DownstreamMessage::readObject(in); 11 | data = boost::static_pointer_cast(in.readObject()); 12 | } 13 | 14 | void BootstrapNotification::writeObject (ObjectOutputStream& out) const 15 | { 16 | presents::net::DownstreamMessage::writeObject(out); 17 | out.writeObject(data); 18 | } 19 | -------------------------------------------------------------------------------- /cpplib/src/presents/data/InvocationMarshaller.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/Streamable.h" 9 | 10 | namespace presents { 11 | 12 | class PresentsClient; 13 | 14 | namespace data { 15 | 16 | class InvocationMarshaller : public Streamable { 17 | public: 18 | DECLARE_STREAMABLE(); 19 | 20 | int32 invOid; 21 | int32 invCode; 22 | 23 | virtual void readObject(ObjectInputStream& in); 24 | virtual void writeObject(ObjectOutputStream& out) const; 25 | }; 26 | 27 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/DSet.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "DSet.h" 3 | 4 | using namespace presents::dobj; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.dobj.DSet", DSet); 7 | 8 | void DSet::readObject (ObjectInputStream& in) 9 | { 10 | size = in.readInt(); 11 | entries = Shared > >(new std::vector< Shared >(size)); 12 | for (int ii = 0; ii < size; ii++) { 13 | (*entries)[ii] = boost::static_pointer_cast(in.readObject()); 14 | } 15 | } 16 | 17 | void DSet::writeObject (ObjectOutputStream& out) const 18 | { 19 | out.writeInt(size); 20 | out.writeField(entries); 21 | } 22 | -------------------------------------------------------------------------------- /tools/src/main/resources/com/threerings/presents/tools/service_listener_as.tmpl: -------------------------------------------------------------------------------- 1 | package {{package}} { 2 | 3 | {{#importGroups}} 4 | {{#this}} 5 | import {{this}}; 6 | {{/this}} 7 | 8 | {{/importGroups}} 9 | /** 10 | * An ActionScript version of the Java {{name}}Service_{{listener.listenerName}}Listener interface. 11 | */ 12 | public interface {{name}}Service_{{listener.listenerName}}Listener 13 | extends InvocationService_InvocationListener 14 | { 15 | {{#listener.methods}} 16 | {{^-first}} 17 | 18 | {{/-first}} 19 | // from Java {{name}}Service_{{listener.listenerName}}Listener 20 | function {{method.name}} ({{getASArgList}}) :void 21 | {{/listener.methods}} 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/EventNotification.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/dobj/DEvent.h" 9 | #include "presents/net/DownstreamMessage.h" 10 | 11 | namespace presents { namespace net { 12 | 13 | class EventNotification : public presents::net::DownstreamMessage { 14 | public: 15 | DECLARE_STREAMABLE(); 16 | 17 | Shared event; 18 | 19 | virtual void readObject(ObjectInputStream& in); 20 | virtual void writeObject(ObjectOutputStream& out) const; 21 | }; 22 | 23 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/net/ForwardEventRequest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/dobj/DEvent.h" 9 | #include "presents/net/UpstreamMessage.h" 10 | 11 | namespace presents { namespace net { 12 | 13 | class ForwardEventRequest : public presents::net::UpstreamMessage { 14 | public: 15 | DECLARE_STREAMABLE(); 16 | 17 | Shared event; 18 | 19 | virtual void readObject(ObjectInputStream& in); 20 | virtual void writeObject(ObjectOutputStream& out) const; 21 | }; 22 | 23 | }} -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/bureau/data/BureauClientObject.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.bureau.data; 7 | 8 | import com.threerings.presents.data.ClientObject; 9 | 10 | /** 11 | * An object representing a Bureau connection. This is currently just a marker class. 12 | */ 13 | public class BureauClientObject extends ClientObject 14 | { 15 | @Override 16 | public String toString () 17 | { 18 | return "BUREAU_CLIENT_OBJECT(" + super.toString() + ")"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/bureau/server/BureauSession.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.bureau.server; 7 | 8 | import com.threerings.presents.server.PresentsSession; 9 | 10 | public class BureauSession extends PresentsSession 11 | { 12 | @Override // from PresentsSession 13 | protected void sessionConnectionClosed () 14 | { 15 | super.sessionConnectionClosed(); 16 | 17 | // end our session when the connection is closed 18 | endSession(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/server/OccupantOp.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.server; 7 | 8 | import com.threerings.crowd.data.OccupantInfo; 9 | 10 | /** 11 | * An operation to be applied to all occupants in a location that may 12 | * contain occupants, e.g., a {@link PlaceManager}. 13 | */ 14 | public interface OccupantOp 15 | { 16 | /** 17 | * Called with the occupant info for each occupant in the location. 18 | */ 19 | void apply (OccupantInfo info); 20 | } 21 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/AuthResponse.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/net/AuthResponseData.h" 9 | #include "presents/net/DownstreamMessage.h" 10 | 11 | namespace presents { namespace net { 12 | 13 | class AuthResponse : public presents::net::DownstreamMessage { 14 | public: 15 | DECLARE_STREAMABLE(); 16 | 17 | Shared data; 18 | 19 | virtual void readObject(ObjectInputStream& in); 20 | virtual void writeObject(ObjectOutputStream& out) const; 21 | }; 22 | 23 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/net/UsernamePasswordCreds.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/net/Credentials.h" 9 | #include "util/Name.h" 10 | 11 | namespace presents { namespace net { 12 | 13 | class UsernamePasswordCreds : public presents::net::Credentials { 14 | public: 15 | DECLARE_STREAMABLE(); 16 | 17 | Shared username; 18 | Shared password; 19 | 20 | virtual void readObject(ObjectInputStream& in); 21 | virtual void writeObject(ObjectOutputStream& out) const; 22 | }; 23 | 24 | }} -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/io/NotStreamable.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.io; 7 | 8 | import java.lang.annotation.ElementType; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | /** 14 | * This annotation specifies that the property or field is not Streamable. 15 | */ 16 | @Target(value=ElementType.FIELD) 17 | @Retention(value=RetentionPolicy.RUNTIME) 18 | public @interface NotStreamable 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/data/InvocationObject.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.data; 7 | 8 | import com.threerings.presents.dobj.DObject; 9 | 10 | /** 11 | * A single invocation object is created by the server invocation manager 12 | * and is used to receive invocation request messages from the client. The 13 | * server presently delivers invocation messages to the client via the 14 | * client object. 15 | */ 16 | public class InvocationObject extends DObject 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/InvocationRequestEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/dobj/DEvent.h" 9 | 10 | namespace presents { namespace dobj { 11 | 12 | class InvocationRequestEvent : public presents::dobj::DEvent { 13 | public: 14 | DECLARE_STREAMABLE(); 15 | 16 | int32 invCode; 17 | int8 methodId; 18 | Shared< std::vector< Shared > > args; 19 | 20 | virtual void readObject(ObjectInputStream& in); 21 | virtual void writeObject(ObjectOutputStream& out) const; 22 | }; 23 | 24 | }} -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/admin/server/persist/ConfigDatum.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.admin.server.persist; 7 | 8 | /** 9 | * Contains a single datum of configuration information. 10 | */ 11 | public class ConfigDatum 12 | { 13 | public String node; 14 | public String object; 15 | public String field; 16 | public String value; 17 | 18 | @Override 19 | public String toString () { 20 | return node + "." + object + "." + field + "=" + value + "]"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/server/BodyLocal.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.server; 7 | 8 | import com.threerings.presents.server.ClientLocal; 9 | 10 | import com.threerings.crowd.data.BodyObject; 11 | 12 | /** 13 | * Contains information tracked for each body by the server. 14 | */ 15 | public class BodyLocal extends ClientLocal 16 | { 17 | /** 18 | * The time at which the {@link BodyObject#status} field was last updated. 19 | */ 20 | public long statusTime; 21 | } 22 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/BootstrapNotification.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/net/BootstrapData.h" 9 | #include "presents/net/DownstreamMessage.h" 10 | 11 | namespace presents { namespace net { 12 | 13 | class BootstrapNotification : public presents::net::DownstreamMessage { 14 | public: 15 | DECLARE_STREAMABLE(); 16 | 17 | Shared data; 18 | 19 | virtual void readObject(ObjectInputStream& in); 20 | virtual void writeObject(ObjectOutputStream& out) const; 21 | }; 22 | 23 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/InvocationNotificationEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/dobj/DEvent.h" 9 | 10 | namespace presents { namespace dobj { 11 | 12 | class InvocationNotificationEvent : public presents::dobj::DEvent { 13 | public: 14 | DECLARE_STREAMABLE(); 15 | 16 | int16 receiverId; 17 | int8 methodId; 18 | Shared< std::vector< Shared > > args; 19 | 20 | virtual void readObject(ObjectInputStream& in); 21 | virtual void writeObject(ObjectOutputStream& out) const; 22 | }; 23 | 24 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/data/ClientObject.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "ClientObject.h" 3 | 4 | using namespace presents::data; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.data.ClientObject", ClientObject); 7 | 8 | void ClientObject::readObject (ObjectInputStream& in) 9 | { 10 | presents::dobj::DObject::readObject(in); 11 | username = boost::static_pointer_cast(in.readObject()); 12 | receivers = boost::static_pointer_cast(in.readObject()); 13 | } 14 | 15 | void ClientObject::writeObject (ObjectOutputStream& out) const 16 | { 17 | presents::dobj::DObject::writeObject(out); 18 | out.writeObject(username); 19 | out.writeObject(receivers); 20 | } 21 | -------------------------------------------------------------------------------- /cpplib/src/presents/data/ClientObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/dobj/DObject.h" 9 | #include "presents/dobj/DSet.h" 10 | #include "util/Name.h" 11 | 12 | namespace presents { namespace data { 13 | 14 | class ClientObject : public presents::dobj::DObject { 15 | public: 16 | DECLARE_STREAMABLE(); 17 | 18 | Shared username; 19 | Shared receivers; 20 | 21 | virtual void readObject(ObjectInputStream& in); 22 | virtual void writeObject(ObjectOutputStream& out) const; 23 | }; 24 | 25 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/net/UsernamePasswordCreds.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "UsernamePasswordCreds.h" 3 | 4 | using namespace presents::net; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.net.UsernamePasswordCreds", UsernamePasswordCreds); 7 | 8 | void UsernamePasswordCreds::readObject (ObjectInputStream& in) 9 | { 10 | presents::net::Credentials::readObject(in); 11 | username = boost::static_pointer_cast(in.readObject()); 12 | password = in.readField< utf8 >(); 13 | } 14 | 15 | void UsernamePasswordCreds::writeObject (ObjectOutputStream& out) const 16 | { 17 | presents::net::Credentials::writeObject(out); 18 | out.writeObject(username); 19 | out.writeField(password); 20 | } 21 | -------------------------------------------------------------------------------- /docs/crowd/notes.txt: -------------------------------------------------------------------------------- 1 | Crowd Notes -*- outline -*- 2 | 3 | * TODO 4 | Wire up PlaceRegistry code to remove registrations when place objects are 5 | destroyed. 6 | 7 | Flesh out the mechanism for passing config information to place managers. 8 | Make it easy to build an inheriting chain of configuration properties. 9 | 10 | Occupant info needs to be stored in place objects. We could create special 11 | list distributed object fields that can store homogenous lists of objects 12 | that implement some sort of serializable interface. Once this is done, 13 | it'll have to be wired up on the server side so that extended occupant 14 | info can be easily provided and on the client side so that that info can 15 | be passed around the client. 16 | -------------------------------------------------------------------------------- /tools/src/main/resources/com/threerings/presents/tools/provider.tmpl: -------------------------------------------------------------------------------- 1 | package {{package}}; 2 | 3 | {{#importGroups}} 4 | {{#this}} 5 | import {{this}}; 6 | {{/this}} 7 | 8 | {{/importGroups}} 9 | /** 10 | * Defines the server-side of the {@link {{name}}Service}. 11 | */ 12 | {{generated}} 13 | public interface {{name}}Provider extends InvocationProvider 14 | { 15 | {{#methods}} 16 | {{^-first}} 17 | 18 | {{/-first}} 19 | /** 20 | * Handles a {@link {{name}}Service#{{method.name}}} request. 21 | */ 22 | {{typeParams}}void {{method.name}} ({{callerType}} caller{{#hasArgs}}, {{/hasArgs}}{{getArgList}}){{^listenerArgs.isEmpty}} 23 | throws InvocationException{{/listenerArgs.isEmpty}}; 24 | {{/methods}} 25 | } 26 | -------------------------------------------------------------------------------- /tools/src/main/resources/com/threerings/presents/tools/cpp/streamable_h.mustache: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | {{#includes}} 9 | #include "{{this}}" 10 | {{/includes}} 11 | 12 | {{#namespaces}}namespace {{this}} { {{/namespaces}} 13 | 14 | class {{name}} : public {{super}} { 15 | public: 16 | DECLARE_STREAMABLE(); 17 | 18 | {{#fields}} 19 | {{type.type}} {{name}}; 20 | {{/fields}} 21 | 22 | virtual void readObject(ObjectInputStream& in); 23 | virtual void writeObject(ObjectOutputStream& out) const; 24 | }; 25 | 26 | {{#namespaces}}}{{/namespaces}} 27 | -------------------------------------------------------------------------------- /cpplib/src/presents/box/BoxedInt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // Generated by running python boxer.py in this directory 3 | 4 | #include "presents/Streamable.h" 5 | #include "presents/streamers/StreamableStreamer.h" 6 | 7 | namespace presents { namespace box { 8 | class BoxedInt : public Streamable{ 9 | public: 10 | DECLARE_STREAMABLE(); 11 | 12 | int32 value; 13 | 14 | static Shared createShared (int32 value) 15 | { 16 | Shared shared(new BoxedInt); 17 | shared->value = value; 18 | return shared; 19 | } 20 | 21 | virtual void readObject(ObjectInputStream& in); 22 | virtual void writeObject(ObjectOutputStream& out) const; 23 | }; 24 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/box/BoxedByte.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // Generated by running python boxer.py in this directory 3 | 4 | #include "presents/Streamable.h" 5 | #include "presents/streamers/StreamableStreamer.h" 6 | 7 | namespace presents { namespace box { 8 | class BoxedByte : public Streamable{ 9 | public: 10 | DECLARE_STREAMABLE(); 11 | 12 | int8 value; 13 | 14 | static Shared createShared (int8 value) 15 | { 16 | Shared shared(new BoxedByte); 17 | shared->value = value; 18 | return shared; 19 | } 20 | 21 | virtual void readObject(ObjectInputStream& in); 22 | virtual void writeObject(ObjectOutputStream& out) const; 23 | }; 24 | }} -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/client/BodyService.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.client; 7 | 8 | import com.threerings.presents.client.InvocationService; 9 | import com.threerings.presents.data.ClientObject; 10 | 11 | /** 12 | * The client side of the body-related invocation services. 13 | */ 14 | public interface BodyService extends InvocationService 15 | { 16 | /** 17 | * Requests to set the idle state of the client to the specified 18 | * value. 19 | */ 20 | void setIdle (boolean idle); 21 | } 22 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/client/PresentsPrefs.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.client; 7 | 8 | import com.samskivert.util.PrefsConfig; 9 | 10 | /** 11 | * Provides access to runtime configuration parameters for this package 12 | * and its subpackages. 13 | */ 14 | public class PresentsPrefs 15 | { 16 | /** Used to load our preferences from a properties file and map them 17 | * to the persistent Java preferences repository. */ 18 | public static PrefsConfig config = new PrefsConfig("rsrc/config/presents"); 19 | } 20 | -------------------------------------------------------------------------------- /cpplib/src/presents/box/BoxedFloat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // Generated by running python boxer.py in this directory 3 | 4 | #include "presents/Streamable.h" 5 | #include "presents/streamers/StreamableStreamer.h" 6 | 7 | namespace presents { namespace box { 8 | class BoxedFloat : public Streamable{ 9 | public: 10 | DECLARE_STREAMABLE(); 11 | 12 | float value; 13 | 14 | static Shared createShared (float value) 15 | { 16 | Shared shared(new BoxedFloat); 17 | shared->value = value; 18 | return shared; 19 | } 20 | 21 | virtual void readObject(ObjectInputStream& in); 22 | virtual void writeObject(ObjectOutputStream& out) const; 23 | }; 24 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/box/BoxedShort.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // Generated by running python boxer.py in this directory 3 | 4 | #include "presents/Streamable.h" 5 | #include "presents/streamers/StreamableStreamer.h" 6 | 7 | namespace presents { namespace box { 8 | class BoxedShort : public Streamable{ 9 | public: 10 | DECLARE_STREAMABLE(); 11 | 12 | int16 value; 13 | 14 | static Shared createShared (int16 value) 15 | { 16 | Shared shared(new BoxedShort); 17 | shared->value = value; 18 | return shared; 19 | } 20 | 21 | virtual void readObject(ObjectInputStream& in); 22 | virtual void writeObject(ObjectOutputStream& out) const; 23 | }; 24 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/net/BootstrapData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/Streamable.h" 9 | #include "presents/data/InvocationMarshaller.h" 10 | 11 | namespace presents { namespace net { 12 | 13 | class BootstrapData : public Streamable { 14 | public: 15 | DECLARE_STREAMABLE(); 16 | 17 | int32 connectionId; 18 | int32 clientOid; 19 | Shared< std::vector< Shared > > services; 20 | 21 | virtual void readObject(ObjectInputStream& in); 22 | virtual void writeObject(ObjectOutputStream& out) const; 23 | }; 24 | 25 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/box/BoxedBoolean.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // Generated by running python boxer.py in this directory 3 | 4 | #include "presents/Streamable.h" 5 | #include "presents/streamers/StreamableStreamer.h" 6 | 7 | namespace presents { namespace box { 8 | class BoxedBoolean : public Streamable{ 9 | public: 10 | DECLARE_STREAMABLE(); 11 | 12 | bool value; 13 | 14 | static Shared createShared (bool value) 15 | { 16 | Shared shared(new BoxedBoolean); 17 | shared->value = value; 18 | return shared; 19 | } 20 | 21 | virtual void readObject(ObjectInputStream& in); 22 | virtual void writeObject(ObjectOutputStream& out) const; 23 | }; 24 | }} -------------------------------------------------------------------------------- /cpplib/src/presents/box/BoxedDouble.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // Generated by running python boxer.py in this directory 3 | 4 | #include "presents/Streamable.h" 5 | #include "presents/streamers/StreamableStreamer.h" 6 | 7 | namespace presents { namespace box { 8 | class BoxedDouble : public Streamable{ 9 | public: 10 | DECLARE_STREAMABLE(); 11 | 12 | double value; 13 | 14 | static Shared createShared (double value) 15 | { 16 | Shared shared(new BoxedDouble); 17 | shared->value = value; 18 | return shared; 19 | } 20 | 21 | virtual void readObject(ObjectInputStream& in); 22 | virtual void writeObject(ObjectOutputStream& out) const; 23 | }; 24 | }} -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/net/LogoffRequest.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.net; 7 | 8 | /** 9 | * Requests to end our session with the server. 10 | */ 11 | public class LogoffRequest extends UpstreamMessage 12 | { 13 | /** 14 | * Zero argument constructor used when unserializing an instance. 15 | */ 16 | public LogoffRequest () 17 | { 18 | super(); 19 | } 20 | 21 | @Override 22 | public String toString () 23 | { 24 | return "[type=LOGOFF, msgid=" + messageId + "]"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/dobj/ChangeListener.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.dobj; 7 | 8 | /** 9 | * The various listener interfaces (e.g. {@link EventListener}, {@link AttributeChangeListener}, 10 | * etc.) all extend this base interface so that the distributed object can check to make sure when 11 | * an object is adding itself as a listener of some sort that it actually implements at least one 12 | * of the listener interfaces. Thus, all listener interfaces must extend this one. 13 | */ 14 | public interface ChangeListener 15 | { 16 | } 17 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/BootstrapData.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "BootstrapData.h" 3 | #include "presents/Streamer.h" 4 | 5 | using namespace presents::net; 6 | 7 | DEFINE_STREAMABLE("com.threerings.presents.net.BootstrapData", BootstrapData); 8 | 9 | void BootstrapData::readObject (ObjectInputStream& in) 10 | { 11 | connectionId = int32(in.readInt()); 12 | clientOid = int32(in.readInt()); 13 | services = boost::static_pointer_cast< std::vector< Shared > >(in.readField(JAVA_LIST_NAME())); 14 | } 15 | 16 | void BootstrapData::writeObject (ObjectOutputStream& out) const 17 | { 18 | out.writeInt(connectionId); 19 | out.writeInt(clientOid); 20 | out.writeField(services, JAVA_LIST_NAME()); 21 | } 22 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/client/RegistrationService.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.client; 7 | 8 | import com.threerings.presents.client.InvocationReceiver.Registration; 9 | import com.threerings.presents.data.ClientObject; 10 | 11 | /** 12 | * Adds a receiver registration for a client that doesn't use DObject and thereby can't use the 13 | * registration set on ClientObject. 14 | */ 15 | public interface RegistrationService 16 | extends InvocationService 17 | { 18 | void registerReceiver(Registration registration); 19 | } 20 | -------------------------------------------------------------------------------- /tools/src/main/resources/com/threerings/presents/tools/cpp/streamable_cpp.mustache: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "{{name}}.h" 3 | {{#includes}} 4 | #include "{{this}}" 5 | {{/includes}} 6 | 7 | using namespace {{namespace}}; 8 | 9 | DEFINE_STREAMABLE("{{javaName}}", {{name}}); 10 | 11 | void {{name}}::readObject (ObjectInputStream& {{inStreamArg}}) 12 | { 13 | {{#superclassStreamable}} 14 | {{super}}::readObject(in); 15 | {{/superclassStreamable}} 16 | {{#fields}} 17 | {{name}} = {{reader}}; 18 | {{/fields}} 19 | } 20 | 21 | void {{name}}::writeObject (ObjectOutputStream& {{outStreamArg}}) const 22 | { 23 | {{#superclassStreamable}} 24 | {{super}}::writeObject(out); 25 | {{/superclassStreamable}} 26 | {{#fields}} 27 | {{writer}}; 28 | {{/fields}} 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/dobj/SimpleEntry.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.dobj; 7 | 8 | import com.threerings.io.Streamable; 9 | 10 | /** 11 | * A quick and easy DSet.Entry that holds some sort of Comparable. 12 | * 13 | * Remember: this type must also be {@link Streamable}. 14 | */ 15 | public class SimpleEntry> 16 | implements DSet.Entry 17 | { 18 | public SimpleEntry (T key) { 19 | _key = key; 20 | } 21 | 22 | public T getKey () { 23 | return _key; 24 | } 25 | 26 | protected T _key; 27 | } 28 | -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/InvocationRequestEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "InvocationRequestEvent.h" 3 | 4 | using namespace presents::dobj; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.dobj.InvocationRequestEvent", InvocationRequestEvent); 7 | 8 | void InvocationRequestEvent::readObject (ObjectInputStream& in) 9 | { 10 | presents::dobj::DEvent::readObject(in); 11 | invCode = int32(in.readInt()); 12 | methodId = int8(in.readByte()); 13 | args = in.readField< std::vector< Shared > >(); 14 | } 15 | 16 | void InvocationRequestEvent::writeObject (ObjectOutputStream& out) const 17 | { 18 | presents::dobj::DEvent::writeObject(out); 19 | out.writeInt(invCode); 20 | out.writeByte(methodId); 21 | out.writeField(args); 22 | } 23 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/net/CompoundDownstreamMessage.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.net; 7 | 8 | import java.util.List; 9 | 10 | import com.google.common.collect.Lists; 11 | 12 | /** 13 | * Groups messages to be dispatched without triggering the message throttle. 14 | */ 15 | public class CompoundDownstreamMessage extends DownstreamMessage 16 | { 17 | public List msgs = Lists.newArrayList(); 18 | 19 | @Override 20 | public String toString () 21 | { 22 | return "[type=COMPOUND, msgid=" + messageId + "]"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/AuthRequest.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/streamers/StreamableStreamer.h" 7 | 8 | #include "presents/net/Credentials.h" 9 | #include "presents/net/UpstreamMessage.h" 10 | 11 | namespace presents { namespace net { 12 | 13 | class AuthRequest : public presents::net::UpstreamMessage { 14 | public: 15 | DECLARE_STREAMABLE(); 16 | 17 | Shared creds; 18 | Shared version; 19 | Shared zone; 20 | Shared< std::vector< Shared > > bootGroups; 21 | 22 | virtual void readObject(ObjectInputStream& in); 23 | virtual void writeObject(ObjectOutputStream& out) const; 24 | }; 25 | 26 | }} -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/bureau/server/BureauClientResolver.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.bureau.server; 7 | 8 | import com.threerings.presents.data.ClientObject; 9 | import com.threerings.presents.server.ClientResolver; 10 | 11 | import com.threerings.bureau.data.BureauClientObject; 12 | 13 | /** 14 | * Used to configure crowd-specific client object data. 15 | */ 16 | public class BureauClientResolver extends ClientResolver 17 | { 18 | @Override // from ClientResolver 19 | public ClientObject createClientObject () 20 | { 21 | return new BureauClientObject(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/dobj/MessageListener.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.dobj; 7 | 8 | /** 9 | * Implemented by entities which wish to hear about message events that are dispatched on a 10 | * particular distributed object. 11 | * 12 | * @see DObject#addListener 13 | */ 14 | public interface MessageListener extends ChangeListener 15 | { 16 | /** 17 | * Called when an message event has been dispatched on an object. 18 | * 19 | * @param event The event that was dispatched on the object. 20 | */ 21 | void messageReceived (MessageEvent event); 22 | } 23 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/peer/net/PeerCreds.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.peer.net; 7 | 8 | import com.threerings.presents.net.ServiceCreds; 9 | 10 | /** 11 | * Used by peer servers in a cluster installation to authenticate with one another. 12 | */ 13 | public class PeerCreds extends ServiceCreds 14 | { 15 | public PeerCreds (String nodeName, String sharedSecret) 16 | { 17 | super(nodeName, sharedSecret); 18 | } 19 | 20 | /** 21 | * Used when unserializing an instance from the network. 22 | */ 23 | public PeerCreds () 24 | { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tools/src/main/resources/com/threerings/presents/tools/dobject_oidlist.tmpl: -------------------------------------------------------------------------------- 1 | /** 2 | * Requests that oid be added to the {{field}} 3 | * oid list. The list will not change until the event is actually 4 | * propagated through the system. 5 | */ 6 | {{generated}} 7 | public void addTo{{upfield}} (int oid) 8 | { 9 | requestOidAdd({{capfield}}, {{field}}, oid); 10 | } 11 | 12 | /** 13 | * Requests that oid be removed from the 14 | * {{field}} oid list. The list will not change until the 15 | * event is actually propagated through the system. 16 | */ 17 | {{generated}} 18 | public void removeFrom{{upfield}} (int oid) 19 | { 20 | requestOidRemove({{capfield}}, {{field}}, oid); 21 | } 22 | -------------------------------------------------------------------------------- /cpplib/src/presents/dobj/InvocationNotificationEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "InvocationNotificationEvent.h" 3 | 4 | using namespace presents::dobj; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.dobj.InvocationNotificationEvent", InvocationNotificationEvent); 7 | 8 | void InvocationNotificationEvent::readObject (ObjectInputStream& in) 9 | { 10 | presents::dobj::DEvent::readObject(in); 11 | receiverId = int16(in.readShort()); 12 | methodId = int8(in.readByte()); 13 | args = in.readField< std::vector< Shared > >(); 14 | } 15 | 16 | void InvocationNotificationEvent::writeObject (ObjectOutputStream& out) const 17 | { 18 | presents::dobj::DEvent::writeObject(out); 19 | out.writeShort(receiverId); 20 | out.writeByte(methodId); 21 | out.writeField(args); 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/threerings/presents/server/PresentsTestBase.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.server; 7 | 8 | import com.google.inject.Guice; 9 | import com.google.inject.Injector; 10 | 11 | /** 12 | * Sets up Guice so that presents things can be tested. 13 | */ 14 | public class PresentsTestBase 15 | { 16 | protected T getInstance (Class clazz) 17 | { 18 | if (_injector == null) { 19 | _injector = Guice.createInjector(new PresentsServer.PresentsModule()); 20 | } 21 | return _injector.getInstance(clazz); 22 | } 23 | 24 | protected Injector _injector; 25 | } 26 | -------------------------------------------------------------------------------- /cpplib/src/presents/Util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace presents { 4 | void log (const char* message); 5 | 6 | namespace internal { 7 | void log (const char* format, ...); 8 | } 9 | 10 | template 11 | inline T reverseBytes (T source) 12 | { 13 | uint8* pData = reinterpret_cast(&source); 14 | std::reverse(pData, pData + sizeof(T)); 15 | return source; 16 | } 17 | 18 | template 19 | T presentsToHost (T source) 20 | { 21 | #ifdef PRESENTS_HOST_LITTLE_ENDIAN 22 | return reverseBytes(source); 23 | #else 24 | return source; 25 | #endif 26 | } 27 | 28 | template 29 | T hostToPresents (T source) 30 | { 31 | #ifdef PRESENTS_HOST_LITTLE_ENDIAN 32 | return reverseBytes(source); 33 | #else 34 | return source; 35 | #endif 36 | } 37 | } -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/dobj/ObjectDeathListener.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.dobj; 7 | 8 | /** 9 | * Implemented by entities which wish to hear about object destruction events. 10 | * 11 | * @see DObject#addListener 12 | */ 13 | public interface ObjectDeathListener extends ChangeListener 14 | { 15 | /** 16 | * Called when this object has been destroyed. This will be called after the event has 17 | * been applied to the object. 18 | * 19 | * @param event The event that was dispatched on the object. 20 | */ 21 | void objectDestroyed (ObjectDestroyedEvent event); 22 | } 23 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/chat/client/ChannelSpeakService.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.chat.client; 7 | 8 | import com.threerings.presents.client.InvocationService; 9 | import com.threerings.presents.data.ClientObject; 10 | 11 | import com.threerings.crowd.chat.data.ChatChannel; 12 | 13 | /** 14 | * Provides a way for clients to speak on chat channels. 15 | */ 16 | public interface ChannelSpeakService extends InvocationService 17 | { 18 | /** 19 | * Requests to speak the supplied message on the specified channel. 20 | */ 21 | public void speak (ChatChannel channel, String message, byte mode); 22 | } 23 | -------------------------------------------------------------------------------- /tools/src/main/resources/com/threerings/presents/tools/cpp/marshaller_cpp.mustache: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "{{name}}.h" 3 | #include "presents/PresentsClient.h" 4 | {{#includes}} 5 | #include "{{this}}" 6 | {{/includes}} 7 | 8 | using namespace {{namespace}}; 9 | 10 | DEFINE_STREAMABLE("{{javaName}}", {{name}}); 11 | 12 | {{#methods}} 13 | void {{name}}::{{methodName}} ({{clientArguments}}) 14 | { 15 | typedef std::vector< Shared > StreamableList; 16 | Shared args(new StreamableList); 17 | {{#serviceArguments}} 18 | args->push_back({{this}}); 19 | {{/serviceArguments}} 20 | args->push_back(getSharedThis()); 21 | client->sendRequest(invOid, invCode, {{-index}}, args); 22 | } 23 | 24 | {{/methods}} 25 | Shared<{{name}}> {{name}}::getSharedThis() 26 | { 27 | return shared_from_this(); 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/bureau/util/BureauContext.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.bureau.util; 7 | 8 | import com.threerings.presents.util.PresentsContext; 9 | 10 | import com.threerings.bureau.client.BureauDirector; 11 | 12 | /** 13 | * Defines the objects held on a bureau client. This includes usual set of objects found on a 14 | * standard presents client. 15 | */ 16 | public interface BureauContext extends PresentsContext 17 | { 18 | /** 19 | * Access the director object. 20 | */ 21 | BureauDirector getBureauDirector (); 22 | 23 | /** 24 | * Access the bureau id. 25 | */ 26 | String getBureauId (); 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/io/Intern.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.io; 7 | 8 | import java.lang.annotation.ElementType; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | /** 14 | * Flags a {@link String} field in a streamable object as being a member of the global string pool 15 | * accessed using {@link String#intern}. Each unique value will be streamed only once, with 16 | * further instances replaced by a compact reference. 17 | */ 18 | @Target({ ElementType.FIELD }) 19 | @Retention(RetentionPolicy.RUNTIME) 20 | public @interface Intern 21 | { 22 | } 23 | -------------------------------------------------------------------------------- /tools/src/main/resources/com/threerings/presents/tools/cpp/decoder_cpp.mustache: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "{{decoderName}}.h" 3 | #include "{{receiverName}}.h" 4 | {{#includes}} 5 | #include "{{this}}" 6 | {{/includes}} 7 | 8 | using namespace {{namespace}}; 9 | 10 | {{decoderName}}::{{decoderName}} (Shared<{{receiverName}}> receiver) : 11 | InvocationDecoder("{{receiverCode}}"), 12 | _receiver(receiver) 13 | { 14 | } 15 | 16 | void {{decoderName}}::dispatchNotification(int8 methodId, const std::vector< Shared >& args) 17 | { 18 | switch(methodId) { 19 | {{#methods}} 20 | case {{-index}}: 21 | _receiver->{{methodName}} ( {{vectorArguments}} ); 22 | return; 23 | {{/methods}} 24 | default: 25 | LOG_INFO("{{decoderName}} got unknown method: %d", methodId); 26 | return; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /cpplib/src/presents/ArrayMask.cpp: -------------------------------------------------------------------------------- 1 | #include "stable.h" 2 | #include "ArrayMask.h" 3 | 4 | ArrayMask::ArrayMask (int length) 5 | { 6 | _length = length/8; 7 | if (length % 8 != 0) { 8 | _length++; 9 | } 10 | _mask = new uint8[_length]; 11 | } 12 | 13 | ArrayMask::ArrayMask (ObjectInputStream& in) 14 | { 15 | _length = in.readShort(); 16 | _mask = new uint8[_length]; 17 | in.readBytes(_mask, _length); 18 | } 19 | 20 | ArrayMask::~ArrayMask() 21 | { 22 | delete _mask; 23 | } 24 | 25 | void ArrayMask::set (int index) 26 | { 27 | _mask[index/8] |= (1 << (index%8)); 28 | } 29 | 30 | bool ArrayMask::isSet (int index) 31 | { 32 | return (_mask[index/8] & (1 << (index%8))) != 0; 33 | } 34 | 35 | void ArrayMask::writeTo (ObjectOutputStream& out) 36 | { 37 | out.writeShort((int16) _length); 38 | out.writeBytes(_mask, _length); 39 | } -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/server/ChainedAuthenticator.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.server; 7 | 8 | import com.threerings.presents.server.net.AuthingConnection; 9 | 10 | /** 11 | * Handles certain special kinds of authentications and passes the remainder through to the default 12 | * authenticator. 13 | */ 14 | public abstract class ChainedAuthenticator extends Authenticator 15 | { 16 | /** 17 | * Derived classes should implement this method and return true if the supplied connection is 18 | * one that they should authenticate. 19 | */ 20 | public abstract boolean shouldHandleConnection (AuthingConnection conn); 21 | } 22 | -------------------------------------------------------------------------------- /cpplib/src/presents/io/FramingOutputStream.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "FramingOutputStream.h" 3 | 4 | #include "presents/Util.h" 5 | 6 | using namespace presents; 7 | 8 | FramingOutputStream::FramingOutputStream (OutputStream* base) 9 | : _base(base) 10 | {} 11 | 12 | // Returns bytes written 13 | size_t FramingOutputStream::write(const uint8* pData, size_t bytesToWrite) 14 | { 15 | uint8* bytes = (uint8*)pData; 16 | for (int ii = 0; ii < bytesToWrite; ii++) { 17 | _frameBuffer.push_back(bytes[ii]); 18 | } 19 | return bytesToWrite; 20 | } 21 | 22 | 23 | void FramingOutputStream::writeFrame() 24 | { 25 | int32 length = hostToPresents((int32)(_frameBuffer.size() + sizeof(int32))); 26 | _base->write((uint8*)&length, sizeof(int32)); 27 | _base->write(&_frameBuffer[0], _frameBuffer.size()); 28 | 29 | _frameBuffer.clear(); 30 | } -------------------------------------------------------------------------------- /tools/src/main/resources/com/threerings/presents/tools/sender.tmpl: -------------------------------------------------------------------------------- 1 | package {{package}}; 2 | 3 | {{#importGroups}} 4 | {{#this}} 5 | import {{this}}; 6 | {{/this}} 7 | 8 | {{/importGroups}} 9 | /** 10 | * Used to issue notifications to a {@link {{name}}Receiver} instance on a 11 | * client. 12 | */ 13 | public class {{name}}Sender extends InvocationSender 14 | { 15 | {{#methods}} 16 | /** 17 | * Issues a notification that will result in a call to {@link 18 | * {{name}}Receiver#{{method.name}}} on a client. 19 | */ 20 | public static void {{senderMethodName}} ( 21 | ClientObject target{{#hasArgs}}, {{/hasArgs}}{{getArgList}}) 22 | { 23 | sendNotification( 24 | target, {{name}}Decoder.RECEIVER_CODE, {{name}}Decoder.{{code}}, 25 | new Object[] { {{getWrappedArgList}} }{{transport}}); 26 | } 27 | 28 | {{/methods}} 29 | } 30 | -------------------------------------------------------------------------------- /cpplib/src/presents/net/AuthRequest.cpp: -------------------------------------------------------------------------------- 1 | #include "presents/stable.h" 2 | #include "AuthRequest.h" 3 | 4 | using namespace presents::net; 5 | 6 | DEFINE_STREAMABLE("com.threerings.presents.net.AuthRequest", AuthRequest); 7 | 8 | void AuthRequest::readObject (ObjectInputStream& in) 9 | { 10 | presents::net::UpstreamMessage::readObject(in); 11 | creds = boost::static_pointer_cast(in.readObject()); 12 | version = in.readField< utf8 >(); 13 | zone = in.readField< utf8 >(); 14 | bootGroups = boost::static_pointer_cast< std::vector< Shared > >(in.readObject()); 15 | } 16 | 17 | void AuthRequest::writeObject (ObjectOutputStream& out) const 18 | { 19 | presents::net::UpstreamMessage::writeObject(out); 20 | out.writeObject(creds); 21 | out.writeField(version); 22 | out.writeField(zone); 23 | out.writeObject(bootGroups); 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/peer/data/ClientInfo.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.peer.data; 7 | 8 | import com.threerings.io.SimpleStreamableObject; 9 | 10 | import com.threerings.util.Name; 11 | 12 | import com.threerings.presents.dobj.DSet; 13 | 14 | /** 15 | * Contains information on a particular client. 16 | */ 17 | public class ClientInfo extends SimpleStreamableObject 18 | implements DSet.Entry 19 | { 20 | /** The username used by this client to authenticate. */ 21 | public Name username; 22 | 23 | // documentation inherited from interface DSet.Entry 24 | public Comparable getKey () 25 | { 26 | return username; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tools/src/main/resources/com/threerings/presents/tools/cpp/marshaller_h.mustache: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamable.h" 4 | #include "presents/ObjectInputStream.h" 5 | #include "presents/ObjectOutputStream.h" 6 | #include "presents/data/InvocationMarshaller.h" 7 | #include "presents/streamers/StreamableStreamer.h" 8 | #include 9 | {{#includes}} 10 | #include "{{this}}" 11 | {{/includes}} 12 | 13 | {{#namespaces}}namespace {{this}} { {{/namespaces}} 14 | 15 | class {{name}} : public presents::data::InvocationMarshaller, public boost::enable_shared_from_this<{{name}}> { 16 | public: 17 | DECLARE_STREAMABLE(); 18 | 19 | virtual ~{{name}} () {} 20 | 21 | {{#methods}} 22 | void {{methodName}} ({{clientArguments}}); 23 | {{/methods}} 24 | protected: 25 | Shared<{{name}}> getSharedThis(); 26 | }; 27 | 28 | {{#namespaces}}}{{/namespaces}} 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/bureau/data/BureauCredentials.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.bureau.data; 7 | 8 | import com.threerings.presents.net.ServiceCreds; 9 | 10 | /** 11 | * Extends the basic credentials to provide bureau-specific fields. 12 | */ 13 | public class BureauCredentials extends ServiceCreds 14 | { 15 | /** 16 | * Creates new credentials for a specific bureau. 17 | */ 18 | public BureauCredentials (String bureauId, String sharedSecret) 19 | { 20 | super(bureauId, sharedSecret); 21 | } 22 | 23 | /** 24 | * Creates an empty credentials for streaming. Should not be used directly. 25 | */ 26 | public BureauCredentials () 27 | { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/io/ClassMapping.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.io; 7 | 8 | /** 9 | * Used by the {@link ObjectOutputStream} and {@link ObjectInputStream} to 10 | * map classes to codes during a session. 11 | */ 12 | class ClassMapping 13 | { 14 | public short code; 15 | public Class sclass; 16 | public Streamer streamer; 17 | 18 | public ClassMapping (short code, Class sclass, Streamer streamer) 19 | { 20 | this.code = code; 21 | this.sclass = sclass; 22 | this.streamer = streamer; 23 | } 24 | 25 | @Override 26 | public String toString () 27 | { 28 | return "[code=" + code + ", class=" + sclass.getName() + "]"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/data/PresentsConMgrStats.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.data; 7 | 8 | import com.threerings.io.Streamable; 9 | import com.threerings.nio.conman.ConMgrStats; 10 | 11 | /** 12 | * Used to track and report stats on the connection manager. 13 | */ 14 | public class PresentsConMgrStats extends ConMgrStats 15 | implements Streamable 16 | { 17 | /** The size of the queue of waiting to auth sockets. This is a snapshot at the time the stats 18 | * are requested. */ 19 | public int authQueueSize; 20 | 21 | @Override // from Object 22 | public PresentsConMgrStats clone () 23 | { 24 | return (PresentsConMgrStats)super.clone(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/net/UpdateThrottleMessage.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.net; 7 | 8 | /** 9 | * Notifies the client that its message throttle has been updated. 10 | */ 11 | public class UpdateThrottleMessage extends DownstreamMessage 12 | { 13 | /** The number of messages allowed per second. */ 14 | public final int messagesPerSec; 15 | 16 | /** 17 | * Zero argument constructor used when unserializing an instance. 18 | */ 19 | public UpdateThrottleMessage () 20 | { 21 | this.messagesPerSec = 0; 22 | } 23 | 24 | public UpdateThrottleMessage (int messagesPerSec) 25 | { 26 | this.messagesPerSec = messagesPerSec; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/net/CompoundUpstreamMessage.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.net; 7 | 8 | import java.util.List; 9 | 10 | import com.google.common.collect.Lists; 11 | 12 | /** 13 | * Groups messages to be dispatched without triggering the message throttle. Any messages sent to 14 | * a client while processing an upstream message will be sent back en masse in a 15 | * CompoundDownstreamMessage. 16 | */ 17 | public class CompoundUpstreamMessage extends UpstreamMessage 18 | { 19 | public List msgs = Lists.newArrayList(); 20 | 21 | @Override 22 | public String toString () 23 | { 24 | return "[type=COMPOUND, msgid=" + messageId + "]"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/server/ClientLocal.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.server; 7 | 8 | import com.threerings.io.SimpleStreamableObject; 9 | 10 | import com.threerings.presents.data.ClientObject; 11 | 12 | /** 13 | * Contains information about a client only tracked on the server. This is configured as a local 14 | * attribute on the {@link ClientObject}. 15 | * 16 | *

Note: this object implements streamable so that it can be cleanly passed between servers in 17 | * a peered environment. It is never sent to the client. 18 | */ 19 | public class ClientLocal extends SimpleStreamableObject 20 | { 21 | /** A shared secret key used for encrypting data. */ 22 | public byte[] secret; 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/server/RegistrationManager.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.server; 7 | 8 | import com.threerings.presents.client.InvocationReceiver.Registration; 9 | import com.threerings.presents.data.ClientObject; 10 | 11 | /** 12 | * Adds receiver registrations for a client. Must be added to an invocation dispatcher to be used. 13 | */ 14 | public class RegistrationManager implements RegistrationProvider 15 | { 16 | public void registerReceiver (ClientObject caller, Registration reg) 17 | { 18 | if (caller.receivers.containsKey(reg.getKey())) { 19 | caller.removeFromReceivers(reg.getKey()); 20 | } 21 | caller.addToReceivers(reg); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/net/ThrottleUpdatedMessage.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.net; 7 | 8 | /** 9 | * Notifies the server that the client has received its {@link UpdateThrottleMessage}. 10 | */ 11 | public class ThrottleUpdatedMessage extends UpstreamMessage 12 | { 13 | /** The number of messages allowed per second. */ 14 | public final int messagesPerSec; 15 | 16 | /** 17 | * Zero argument constructor used when unserializing an instance. 18 | */ 19 | public ThrottleUpdatedMessage () 20 | { 21 | this.messagesPerSec = 0; 22 | } 23 | 24 | public ThrottleUpdatedMessage (int messagesPerSec) 25 | { 26 | this.messagesPerSec = messagesPerSec; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/server/BodyProvider.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.server; 7 | 8 | import javax.annotation.Generated; 9 | 10 | import com.threerings.presents.data.ClientObject; 11 | import com.threerings.presents.server.InvocationProvider; 12 | 13 | import com.threerings.crowd.client.BodyService; 14 | 15 | /** 16 | * Defines the server-side of the {@link BodyService}. 17 | */ 18 | @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, 19 | comments="Derived from BodyService.java.") 20 | public interface BodyProvider extends InvocationProvider 21 | { 22 | /** 23 | * Handles a {@link BodyService#setIdle} request. 24 | */ 25 | void setIdle (ClientObject caller, boolean arg1); 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/dobj/AccessController.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.dobj; 7 | 8 | /** 9 | * Used to validate distributed object subscription requests and event 10 | * dispatches. 11 | * 12 | * @see DObject#setAccessController 13 | */ 14 | public interface AccessController 15 | { 16 | /** 17 | * Should return true if the supplied subscriber is allowed to 18 | * subscribe to the specified object. 19 | */ 20 | boolean allowSubscribe (DObject object, Subscriber subscriber); 21 | 22 | /** 23 | * Should return true if the supplied event is legal for dispatch on 24 | * the specified distributed object. 25 | */ 26 | boolean allowDispatch (DObject object, DEvent event); 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/client/LocationReceiver.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.client; 7 | 8 | import com.threerings.presents.client.InvocationReceiver; 9 | 10 | /** 11 | * Defines, for the location services, a set of notifications delivered 12 | * asynchronously by the server to the client. 13 | */ 14 | public interface LocationReceiver extends InvocationReceiver 15 | { 16 | /** 17 | * Used to communicate a required move notification to the client. The 18 | * server will have removed the client from their existing location 19 | * and the client is then responsible for generating a {@link 20 | * LocationService#moveTo} request to move to the new location. 21 | */ 22 | void forcedMove (int placeId); 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/server/ClientResolutionListener.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.server; 7 | 8 | import com.threerings.util.Name; 9 | 10 | import com.threerings.presents.data.ClientObject; 11 | 12 | /** 13 | * Entites that wish to resolve client objects must implement this 14 | * interface so as to partake in the asynchronous process of client 15 | * object resolution. 16 | */ 17 | public interface ClientResolutionListener 18 | { 19 | /** 20 | * Called when resolution completed successfully. 21 | */ 22 | void clientResolved (Name username, ClientObject clobj); 23 | 24 | /** 25 | * Called when resolution fails. 26 | */ 27 | void resolutionFailed (Name username, Exception reason); 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/annotation/AuthInvoker.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.annotation; 7 | 8 | import java.lang.annotation.ElementType; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | import com.google.inject.BindingAnnotation; 14 | 15 | /** 16 | * An annotation that identifies the invoker on which we do client authentication. This would 17 | * generally only be used to bind the auth invoker to a different invoker than the default (which 18 | * is the main invoker). 19 | */ 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Target({ ElementType.FIELD, ElementType.PARAMETER }) 22 | @BindingAnnotation 23 | public @interface AuthInvoker 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /core/src/test/java/com/threerings/crowd/data/JabberConfig.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.data; 7 | 8 | import com.threerings.crowd.client.JabberController; 9 | import com.threerings.crowd.client.PlaceController; 10 | 11 | /** 12 | * Defines the necessary bits for our chat room. 13 | */ 14 | public class JabberConfig extends PlaceConfig 15 | { 16 | // documentation inherited 17 | @Override 18 | public PlaceController createController () 19 | { 20 | return new JabberController(); 21 | } 22 | 23 | // documentation inherited 24 | @Override 25 | public String getManagerClassName () 26 | { 27 | // nothing special needed on the server side 28 | return "com.threerings.crowd.server.PlaceManager"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/server/CrowdClientResolver.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.server; 7 | 8 | import com.threerings.presents.data.ClientObject; 9 | import com.threerings.presents.server.ClientLocal; 10 | import com.threerings.presents.server.ClientResolver; 11 | 12 | import com.threerings.crowd.data.BodyObject; 13 | 14 | /** 15 | * Used to configure crowd-specific client object data. 16 | */ 17 | public class CrowdClientResolver extends ClientResolver 18 | { 19 | @Override // from ClientResolver 20 | public ClientObject createClientObject () 21 | { 22 | return new BodyObject(); 23 | } 24 | 25 | @Override 26 | public ClientLocal createLocalAttribute () 27 | { 28 | return new BodyLocal(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/chat/server/SpeakProvider.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.chat.server; 7 | 8 | import javax.annotation.Generated; 9 | 10 | import com.threerings.presents.data.ClientObject; 11 | import com.threerings.presents.server.InvocationProvider; 12 | 13 | import com.threerings.crowd.chat.client.SpeakService; 14 | 15 | /** 16 | * Defines the server-side of the {@link SpeakService}. 17 | */ 18 | @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, 19 | comments="Derived from SpeakService.java.") 20 | public interface SpeakProvider extends InvocationProvider 21 | { 22 | /** 23 | * Handles a {@link SpeakService#speak} request. 24 | */ 25 | void speak (ClientObject caller, String arg1, byte arg2); 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/server/PresentsAuthInvoker.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.server; 7 | 8 | import com.google.inject.Inject; 9 | import com.google.inject.Singleton; 10 | 11 | /** 12 | * A separate invoker thread on which we perform client authentication. This allows the normal 13 | * server operation to proceed even in the event that our authentication services have gone down 14 | * and attempts to authenticate cause long timeouts and blockage. 15 | */ 16 | @Singleton 17 | public class PresentsAuthInvoker extends ReportingInvoker 18 | { 19 | @Inject public PresentsAuthInvoker (PresentsDObjectMgr omgr, ReportManager repmgr) 20 | { 21 | super("presents.AuthInvoker", omgr, repmgr); 22 | setDaemon(true); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/net/DownstreamMessage.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.net; 7 | 8 | /** 9 | * This class encapsulates a message in the distributed object protocol that flows from the server 10 | * to the client. Downstream messages include object subscription, event forwarding and session 11 | * management. 12 | */ 13 | public abstract class DownstreamMessage extends Message 14 | { 15 | /** 16 | * The message id of the upstream message with which this downstream message is associated (or 17 | * -1 if it is not associated with any upstream message). 18 | */ 19 | public short messageId = -1; 20 | 21 | @Override 22 | public String toString () 23 | { 24 | return "[msgid=" + messageId + "]"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/annotation/AnyThread.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.annotation; 7 | 8 | import java.lang.annotation.ElementType; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | /** 14 | * An annotation indicating that a particular method in a class is safe to be called from any 15 | * thread. This is not allowed on a class because it serves purely as documentation to demonstrate 16 | * specific situations where methods are intended to be used by both the event dispatch and 17 | * blocking threads which are generally uncommon. 18 | */ 19 | @Target(value=ElementType.METHOD) 20 | @Retention(value=RetentionPolicy.SOURCE) 21 | public @interface AnyThread 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /docs/miso/scene.ps: -------------------------------------------------------------------------------- 1 | % sort out scaling and translating 2 | 36 36 translate 3 | /sf 540 640 div def 4 | sf sf scale 5 | 6 | % width/height ratio 7 | /whr 10 7.5 div def 8 | 9 | % center things vertically 10 | 0 whr 640 mul 576 sub 2 div translate 11 | 12 | % translate off to the left one tile and clip 13 | 64 neg 0 translate 14 | 64 0 640 576 rectclip 15 | 16 | % draw the up moving diagnals 17 | /sx 0 def 18 | /sy 288 def 19 | /ex 384 def 20 | /ey 576 def 21 | 22 | 1 1 13 { 23 | sx sy moveto 24 | ex ey lineto 25 | stroke 26 | /sx sx 32 add def 27 | /ex ex 32 add def 28 | /sy sy 24 sub def 29 | /ey ey 24 sub def 30 | } for 31 | 32 | % draw the down moving diagnals 33 | /sx 0 def 34 | /sy 288 def 35 | /ex 384 def 36 | /ey 0 def 37 | 38 | 1 1 13 { 39 | sx sy moveto 40 | ex ey lineto 41 | stroke 42 | /sx sx 32 add def 43 | /ex ex 32 add def 44 | /sy sy 24 add def 45 | /ey ey 24 add def 46 | } for 47 | 48 | % box the whole thing in 49 | 64 0 640 576 rectstroke 50 | 51 | showpage 52 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/chat/client/ChatFilter.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.chat.client; 7 | 8 | import com.threerings.util.Name; 9 | 10 | /** 11 | * Filters messages chat messages to or from the server. 12 | */ 13 | public interface ChatFilter 14 | { 15 | /** 16 | * Filter a chat message. 17 | * @param msg the message text to be filtered. 18 | * @param otherUser an optional argument that represents the target or the speaker, depending 19 | * on 'outgoing', and can be considered in filtering if it is provided. 20 | * @param outgoing true if the message is going out to the server. 21 | * 22 | * @return the filtered message, or null to block it completely. 23 | */ 24 | String filter (String msg, Name otherUser, boolean outgoing); 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/net/AuthResponseData.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.net; 7 | 8 | import com.threerings.presents.dobj.DObject; 9 | 10 | /** 11 | * An AuthResponseData object is communicated back to the 12 | * client along with an authentication response. It contains an indicator 13 | * of authentication success or failure along with bootstrap information 14 | * for the client. 15 | */ 16 | public class AuthResponseData extends DObject 17 | { 18 | /** The constant used to indicate a successful authentication. */ 19 | public static final String SUCCESS = "success"; 20 | 21 | /** 22 | * Either the {@link #SUCCESS} constant or a reason code indicating 23 | * why the authentication failed. 24 | */ 25 | public String code; 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/dobj/ElementUpdateListener.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.dobj; 7 | 8 | /** 9 | * Implemented by entities which wish to hear about element updates that take place for a 10 | * particular distributed object. 11 | * 12 | * @see DObject#addListener 13 | */ 14 | public interface ElementUpdateListener extends ChangeListener 15 | { 16 | /** 17 | * Called when an element updated event has been dispatched on an object. This will be called 18 | * after the event has been applied to the object. So fetching the element during 19 | * this call will provide the new value for the element. 20 | * 21 | * @param event The event that was dispatched on the object. 22 | */ 23 | void elementUpdated (ElementUpdatedEvent event); 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/bureau/client/Agent.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.bureau.client; 7 | 8 | import com.threerings.bureau.data.AgentObject; 9 | 10 | /** 11 | * Represents an agent running within a bureau client. 12 | */ 13 | public abstract class Agent 14 | { 15 | /** 16 | * Initializes the Agent with the distributed agent object. 17 | */ 18 | public void init (AgentObject agentObj) 19 | { 20 | _agentObj = agentObj; 21 | } 22 | 23 | /** 24 | * Starts the code running in the agent. 25 | */ 26 | public abstract void start (); 27 | 28 | /** 29 | * Stops the code running in the agent. 30 | */ 31 | public abstract void stop (); 32 | 33 | /** 34 | * The shared agent object. 35 | */ 36 | protected AgentObject _agentObj; 37 | } 38 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/dobj/AttributeChangeListener.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.dobj; 7 | 8 | /** 9 | * Implemented by entities which wish to hear about attribute changes that take place for a 10 | * particular distributed object. 11 | * 12 | * @see DObject#addListener 13 | */ 14 | public interface AttributeChangeListener extends ChangeListener 15 | { 16 | /** 17 | * Called when an attribute changed event has been dispatched on an object. This will be 18 | * called after the event has been applied to the object. So fetching the attribute 19 | * during this call will provide the new value for the attribute. 20 | * 21 | * @param event The event that was dispatched on the object. 22 | */ 23 | void attributeChanged (AttributeChangedEvent event); 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/annotation/PeerInvoker.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.annotation; 7 | 8 | import java.lang.annotation.ElementType; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | import com.google.inject.BindingAnnotation; 14 | 15 | import com.samskivert.util.Invoker; 16 | 17 | /** 18 | * An annotation that identifies the peer {@link Invoker}. Code that requires the ability 19 | * to post units for execution on the peer invoker thread can inject this queue like so: 20 | * 21 | * @Inject @PeerInvoker Invoker _invoker; 22 | */ 23 | @Retention(RetentionPolicy.RUNTIME) 24 | @Target({ ElementType.FIELD, ElementType.PARAMETER }) 25 | @BindingAnnotation 26 | public @interface PeerInvoker 27 | { 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/server/RegistrationProvider.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.server; 7 | 8 | import javax.annotation.Generated; 9 | 10 | import com.threerings.presents.client.InvocationReceiver; 11 | import com.threerings.presents.client.RegistrationService; 12 | import com.threerings.presents.data.ClientObject; 13 | 14 | /** 15 | * Defines the server-side of the {@link RegistrationService}. 16 | */ 17 | @Generated(value={"com.threerings.presents.tools.cpp.GenCPPServiceTask"}, 18 | comments="Derived from RegistrationService.java.") 19 | public interface RegistrationProvider extends InvocationProvider 20 | { 21 | /** 22 | * Handles a {@link RegistrationService#registerReceiver} request. 23 | */ 24 | void registerReceiver (ClientObject caller, InvocationReceiver.Registration arg1); 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/annotation/MainInvoker.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.annotation; 7 | 8 | import java.lang.annotation.ElementType; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | import com.google.inject.BindingAnnotation; 14 | 15 | import com.samskivert.util.Invoker; 16 | 17 | /** 18 | * An annotation that identifies the main Presents {@link Invoker}. Code that requires the ability 19 | * to post units for execution on the main invoker thread can inject this queue like so: 20 | * 21 | * @Inject @MainInvoker Invoker _invoker; 22 | */ 23 | @Retention(RetentionPolicy.RUNTIME) 24 | @Target({ ElementType.FIELD, ElementType.PARAMETER }) 25 | @BindingAnnotation 26 | public @interface MainInvoker 27 | { 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/annotation/TransportHint.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.annotation; 7 | 8 | import java.lang.annotation.ElementType; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | import com.threerings.presents.net.Transport; 14 | 15 | /** 16 | * An annotation indicating the type of transport desired for a distributed object 17 | * class, field, or method. 18 | */ 19 | @Target({ ElementType.FIELD, ElementType.METHOD, ElementType.TYPE }) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | public @interface TransportHint 22 | { 23 | /** The type of transport to use. */ 24 | Transport.Type type () default Transport.Type.RELIABLE_ORDERED; 25 | 26 | /** For ordered transport types, the channel to use. */ 27 | int channel () default 0; 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/annotation/EventQueue.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.annotation; 7 | 8 | import java.lang.annotation.ElementType; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | import com.google.inject.BindingAnnotation; 14 | 15 | import com.samskivert.util.RunQueue; 16 | 17 | /** 18 | * An annotation that identifies the distributed object event dispatcher's {@link RunQueue}. Code 19 | * that requires the ability to post runnables for execution on the event dispatcher thread can 20 | * inject this queue like so: 21 | * 22 | * @Inject @EventQueue RunQueue _dobjq; 23 | */ 24 | @Retention(RetentionPolicy.RUNTIME) 25 | @Target({ ElementType.FIELD, ElementType.PARAMETER }) 26 | @BindingAnnotation 27 | public @interface EventQueue 28 | { 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/admin/web/gwt/ConfigServiceAsync.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.admin.web.gwt; 7 | 8 | import com.google.gwt.user.client.rpc.AsyncCallback; 9 | 10 | import com.threerings.admin.web.gwt.ConfigService.ConfigurationRecord; 11 | import com.threerings.admin.web.gwt.ConfigService.ConfigurationResult; 12 | 13 | /** 14 | * Provides the asynchronous version of {@link ConfigService}. 15 | */ 16 | public interface ConfigServiceAsync 17 | { 18 | /** 19 | * The async version of {@link ConfigService#getConfiguration}. 20 | */ 21 | public void getConfiguration (AsyncCallback callback); 22 | 23 | /** 24 | * The async version of {@link ConfigService#updateConfiguration}. 25 | */ 26 | public void updateConfiguration ( 27 | String key, ConfigField[] updates, AsyncCallback callback); 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/chat/server/ChannelSpeakProvider.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.chat.server; 7 | 8 | import javax.annotation.Generated; 9 | 10 | import com.threerings.presents.data.ClientObject; 11 | import com.threerings.presents.server.InvocationProvider; 12 | 13 | import com.threerings.crowd.chat.client.ChannelSpeakService; 14 | import com.threerings.crowd.chat.data.ChatChannel; 15 | 16 | /** 17 | * Defines the server-side of the {@link ChannelSpeakService}. 18 | */ 19 | @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, 20 | comments="Derived from ChannelSpeakService.java.") 21 | public interface ChannelSpeakProvider extends InvocationProvider 22 | { 23 | /** 24 | * Handles a {@link ChannelSpeakService#speak} request. 25 | */ 26 | void speak (ClientObject caller, ChatChannel arg1, String arg2, byte arg3); 27 | } 28 | -------------------------------------------------------------------------------- /core/src/test/java/com/threerings/crowd/server/JabberServer.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.server; 7 | 8 | import com.google.inject.Injector; 9 | 10 | import com.threerings.crowd.data.JabberConfig; 11 | 12 | /** 13 | * A basic server that creates a single room and sticks everyone in it where they can chat with one 14 | * another. 15 | */ 16 | public class JabberServer extends CrowdServer 17 | { 18 | public static void main (String[] args) 19 | { 20 | runServer(new CrowdModule(), new PresentsServerModule(JabberServer.class)); 21 | } 22 | 23 | @Override // from CrowdServer 24 | public void init (Injector injector) 25 | throws Exception 26 | { 27 | super.init(injector); 28 | 29 | // create a single location 30 | _pmgr = _plreg.createPlace(new JabberConfig()); 31 | } 32 | 33 | protected PlaceManager _pmgr; 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/admin/server/AdminProvider.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.admin.server; 7 | 8 | import javax.annotation.Generated; 9 | 10 | import com.threerings.presents.data.ClientObject; 11 | import com.threerings.presents.server.InvocationException; 12 | import com.threerings.presents.server.InvocationProvider; 13 | 14 | import com.threerings.admin.client.AdminService; 15 | 16 | /** 17 | * Defines the server-side of the {@link AdminService}. 18 | */ 19 | @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, 20 | comments="Derived from AdminService.java.") 21 | public interface AdminProvider extends InvocationProvider 22 | { 23 | /** 24 | * Handles a {@link AdminService#getConfigInfo} request. 25 | */ 26 | void getConfigInfo (ClientObject caller, AdminService.ConfigInfoListener arg1) 27 | throws InvocationException; 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/dobj/NamedElementUpdateListener.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.dobj; 7 | 8 | /** 9 | * An ElementUpdateListener that listens for changes with a given name and calls 10 | * namedElementUpdated when they occur. 11 | */ 12 | public abstract class NamedElementUpdateListener 13 | implements ElementUpdateListener 14 | { 15 | /** 16 | * Listen for element updates with the given name. 17 | */ 18 | public NamedElementUpdateListener (String name) 19 | { 20 | _name = name; 21 | } 22 | 23 | final public void elementUpdated (ElementUpdatedEvent event) 24 | { 25 | if (event.getName().equals(_name)) { 26 | namedElementUpdated(event); 27 | } 28 | } 29 | 30 | abstract protected void namedElementUpdated (ElementUpdatedEvent event); 31 | 32 | protected final String _name; 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/annotation/EventThread.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.annotation; 7 | 8 | import java.lang.annotation.ElementType; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | /** 14 | * An annotation indicating that a particular method or all methods in a class (that are not 15 | * otherwise explicitly annotated) should only be called while on the distributed object event 16 | * dispatch thread. 17 | * 18 | * NOTE: These annotations are currently merely advisory, but someday we would like to use AspectJ 19 | * or something like that to inject code that enforces these requirements on dev server builds. 20 | */ 21 | @Target(value={ ElementType.METHOD, ElementType.TYPE }) 22 | @Retention(value=RetentionPolicy.SOURCE) 23 | public @interface EventThread 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/dobj/EventListener.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.dobj; 7 | 8 | /** 9 | * Implemented by entities which wish to hear about all events being dispatched on a particular 10 | * distributed object. 11 | * 12 | * @see DObject#addListener 13 | */ 14 | public interface EventListener extends ChangeListener 15 | { 16 | /** 17 | * Called when any event has been dispatched on an object. The event will be of the derived 18 | * class that corresponds to the kind of event that occurred on the object. This will be 19 | * called after the event has been applied to the object. So fetching an attribute 20 | * upon receiving an attribute changed event will provide the new value for the attribute. 21 | * 22 | * @param event The event that was dispatched on the object. 23 | */ 24 | void eventReceived (DEvent event); 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/chat/client/ChatDisplay.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.chat.client; 7 | 8 | import com.threerings.crowd.chat.data.ChatMessage; 9 | 10 | /** 11 | * A chat display provides a means by which chat messages can be 12 | * displayed. The chat display will be notified when chat messages of 13 | * various sorts have been received by the client. 14 | */ 15 | public interface ChatDisplay 16 | { 17 | /** 18 | * Called to clear the chat display. 19 | */ 20 | void clear (); 21 | 22 | /** 23 | * Called to display a chat message. 24 | * 25 | * @param alreadyDisplayed true if a previous chat display in the list has 26 | * already displayed this message, false otherwise. 27 | * 28 | * @return true if the message was displayed, false if not. 29 | */ 30 | boolean displayMessage (ChatMessage msg, boolean alreadyDisplayed); 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/annotation/BlockingThread.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.annotation; 7 | 8 | import java.lang.annotation.ElementType; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | /** 14 | * An annotation indicating that a particular method or all methods in a class (that are not 15 | * otherwise explicitly annotated) should only be called while on a servlet or invoker thread 16 | * (threads which allow blocking). 17 | * 18 | * NOTE: These annotations are currently merely advisory, but someday we would like to use AspectJ 19 | * or something like that to inject code that enforces these requirements on dev server builds. 20 | */ 21 | @Target(value={ ElementType.METHOD, ElementType.TYPE }) 22 | @Retention(value=RetentionPolicy.SOURCE) 23 | public @interface BlockingThread 24 | { 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/admin/client/AdminService.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.admin.client; 7 | 8 | import com.threerings.presents.client.InvocationService; 9 | import com.threerings.presents.data.ClientObject; 10 | 11 | /** 12 | * Defines the client side of the admin invocation services. 13 | */ 14 | public interface AdminService extends InvocationService 15 | { 16 | /** 17 | * Used to communicate a response to a {@link AdminService#getConfigInfo} request. 18 | */ 19 | public static interface ConfigInfoListener extends InvocationListener 20 | { 21 | /** 22 | * Delivers a successful response to a {@link AdminService#getConfigInfo} request. 23 | */ 24 | void gotConfigInfo (String[] keys, int[] oids); 25 | } 26 | 27 | /** 28 | * Requests the list of config objects. 29 | */ 30 | void getConfigInfo (ConfigInfoListener listener); 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/client/ClientObjectInputStream.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.client; 7 | 8 | import java.io.InputStream; 9 | 10 | import com.threerings.io.ObjectInputStream; 11 | 12 | /** 13 | * A specialized {@link ObjectInputStream} used in conjunction with {@link Client} to allow 14 | * instances that are read from the stream to obtain a client reference "on their way in". We use 15 | * this to allow invocation marshallers to get a reference to the client with which they are 16 | * associated when they are streamed in over the network. 17 | */ 18 | public class ClientObjectInputStream extends ObjectInputStream 19 | { 20 | /** The client with which this input stream is associated. */ 21 | public final Client client; 22 | 23 | public ClientObjectInputStream (Client client, InputStream source) 24 | { 25 | super(source); 26 | this.client = client; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/client/LoggingListener.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.client; 7 | 8 | import com.samskivert.util.Logger; 9 | 10 | /** 11 | * Implements the basic {@link InvocationService.InvocationListener} and logs the failure. 12 | */ 13 | public class LoggingListener 14 | implements InvocationService.InvocationListener 15 | { 16 | /** 17 | * Constructs a listener that will report the supplied error message along with the reason for 18 | * failure to the supplied log object. 19 | */ 20 | public LoggingListener (Logger log, String errmsg) 21 | { 22 | _logger = log; 23 | _errmsg = errmsg; 24 | } 25 | 26 | // documentation inherited from interface 27 | public void requestFailed (String reason) 28 | { 29 | _logger.warning(_errmsg + " [reason=" + reason + "]."); 30 | } 31 | 32 | protected Logger _logger; 33 | protected String _errmsg; 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/net/SecureRequest.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.net; 7 | 8 | import java.security.PrivateKey; 9 | 10 | /** 11 | * Used to create a secure channel to the server. 12 | */ 13 | public class SecureRequest extends AuthRequest 14 | { 15 | /** 16 | * Zero argument constructor used when unserializing an instance. 17 | */ 18 | public SecureRequest () 19 | { 20 | super(); 21 | } 22 | 23 | /** 24 | * Constructs a auth request with the supplied credentials and client version information. 25 | */ 26 | public SecureRequest (PublicKeyCredentials creds, String version) 27 | { 28 | super(creds, version, new String[0]); 29 | } 30 | 31 | /** 32 | * Returns the secret from the credentials. 33 | */ 34 | public byte[] getSecret (PrivateKey key) 35 | { 36 | return ((PublicKeyCredentials)_creds).getSecret(key); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/java/com/threerings/presents/server/TestSender.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.server; 7 | 8 | import com.threerings.presents.client.TestDecoder; 9 | import com.threerings.presents.client.TestReceiver; 10 | import com.threerings.presents.data.ClientObject; 11 | import com.threerings.presents.server.InvocationSender; 12 | 13 | /** 14 | * Used to issue notifications to a {@link TestReceiver} instance on a 15 | * client. 16 | */ 17 | public class TestSender extends InvocationSender 18 | { 19 | /** 20 | * Issues a notification that will result in a call to {@link 21 | * TestReceiver#receivedTest} on a client. 22 | */ 23 | public static void sendTest ( 24 | ClientObject target, int arg1, String arg2) 25 | { 26 | sendNotification( 27 | target, TestDecoder.RECEIVER_CODE, TestDecoder.RECEIVED_TEST, 28 | new Object[] { Integer.valueOf(arg1), arg2 }); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/server/LocationSender.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.server; 7 | 8 | import com.threerings.presents.data.ClientObject; 9 | import com.threerings.presents.server.InvocationSender; 10 | 11 | import com.threerings.crowd.client.LocationDecoder; 12 | import com.threerings.crowd.client.LocationReceiver; 13 | 14 | /** 15 | * Used to issue notifications to a {@link LocationReceiver} instance on a 16 | * client. 17 | */ 18 | public class LocationSender extends InvocationSender 19 | { 20 | /** 21 | * Issues a notification that will result in a call to {@link 22 | * LocationReceiver#forcedMove} on a client. 23 | */ 24 | public static void forcedMove ( 25 | ClientObject target, int arg1) 26 | { 27 | sendNotification( 28 | target, LocationDecoder.RECEIVER_CODE, LocationDecoder.FORCED_MOVE, 29 | new Object[] { Integer.valueOf(arg1) }); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/dobj/ProxySubscriber.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.dobj; 7 | 8 | import com.threerings.presents.data.ClientObject; 9 | 10 | /** 11 | * Defines a special kind of subscriber that proxies events for a subordinate distributed object 12 | * manager. All events dispatched on objects with which this subscriber is registered are passed 13 | * along to the subscriber for delivery to its subordinate manager. 14 | * 15 | * @see DObject#addListener 16 | */ 17 | public interface ProxySubscriber extends Subscriber 18 | { 19 | /** 20 | * Called when any event has been dispatched on an object. 21 | * 22 | * @param event The event that was dispatched on the object. 23 | */ 24 | void eventReceived (DEvent event); 25 | 26 | /** 27 | * Returns the client object that represents the subscriber for whom we are proxying. 28 | */ 29 | ClientObject getClientObject (); 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/net/BootstrapData.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.net; 7 | 8 | import java.util.List; 9 | 10 | import com.threerings.io.SimpleStreamableObject; 11 | 12 | import com.threerings.presents.data.InvocationMarshaller; 13 | 14 | /** 15 | * A BootstrapData object is communicated back to the client after authentication has 16 | * succeeded and after the server is fully prepared to deal with the client. It contains 17 | * information the client will need to interact with the server. 18 | */ 19 | public class BootstrapData extends SimpleStreamableObject 20 | { 21 | /** The unique id of the client's connection (used to address datagrams). */ 22 | public int connectionId; 23 | 24 | /** The oid of this client's associated distributed object. */ 25 | public int clientOid; 26 | 27 | /** A list of handles to invocation services. */ 28 | public List> services; 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/client/OccupantAdapter.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.client; 7 | 8 | import com.threerings.crowd.data.OccupantInfo; 9 | 10 | /** 11 | * The occupant adapter makes life easier for occupant observer classes 12 | * that only care about one or two of the occupant observer 13 | * callbacks. They can either extend occupant adapter or create an 14 | * anonymous class that extends it and overrides just the callbacks they 15 | * care about. 16 | */ 17 | public class OccupantAdapter implements OccupantObserver 18 | { 19 | // documentation inherited from interface 20 | public void occupantEntered (OccupantInfo info) 21 | { 22 | } 23 | 24 | // documentation inherited from interface 25 | public void occupantLeft (OccupantInfo info) 26 | { 27 | } 28 | 29 | // documentation inherited from interface 30 | public void occupantUpdated (OccupantInfo oinfo, OccupantInfo info) 31 | { 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/web/gwt/ServiceException.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.web.gwt; 7 | 8 | /** 9 | * An exception thrown by a remote service when it wishes to communicate a 10 | * particular error message to a user. 11 | */ 12 | public class ServiceException extends Exception 13 | { 14 | /** 15 | * Creates a service exception with the supplied translation message. 16 | */ 17 | public ServiceException (String message) 18 | { 19 | _message = message; 20 | } 21 | 22 | /** 23 | * Default constructor for use when unserializing. 24 | */ 25 | public ServiceException () 26 | { 27 | } 28 | 29 | @Override // from Exception 30 | public String getMessage () 31 | { 32 | // we have to return our own message because GWT won't serialize anything in our parent 33 | // class without a bunch of annoying fiddling 34 | return _message; 35 | } 36 | 37 | protected String _message; 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/data/Place.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.data; 7 | 8 | import com.threerings.io.SimpleStreamableObject; 9 | 10 | /** 11 | * Contains information on the current place occupied by a body. 12 | */ 13 | public class Place extends SimpleStreamableObject 14 | { 15 | /** The oid of this place's {@link PlaceObject}. */ 16 | public final int placeOid; 17 | 18 | /** 19 | * Creates a place with the supplied oid. 20 | */ 21 | public Place (int placeOid) 22 | { 23 | this.placeOid = placeOid; 24 | } 25 | 26 | @Override // from Object 27 | public boolean equals (Object other) 28 | { 29 | if (other == null) { 30 | return false; 31 | } 32 | return getClass().equals(other.getClass()) ? placeOid == ((Place)other).placeOid : false; 33 | } 34 | 35 | @Override // from Object 36 | public int hashCode () 37 | { 38 | return placeOid; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/client/TimeBaseService.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.client; 7 | 8 | import com.threerings.presents.data.ClientObject; 9 | 10 | /** 11 | * Provides a means by which to obtain access to a time base object which can be used to convert 12 | * delta times into absolute times. 13 | */ 14 | public interface TimeBaseService extends InvocationService 15 | { 16 | /** 17 | * Used to communicated the result of a {@link TimeBaseService#getTimeOid} request. 18 | */ 19 | public static interface GotTimeBaseListener extends InvocationListener 20 | { 21 | /** 22 | * Communicates the result of a successful {@link TimeBaseService#getTimeOid} request. 23 | */ 24 | void gotTimeOid (int timeOid); 25 | } 26 | 27 | /** 28 | * Requests the oid of the specified time base object be fetched. 29 | */ 30 | void getTimeOid (String timeBase, GotTimeBaseListener listener); 31 | } 32 | -------------------------------------------------------------------------------- /docs/micasa/design.txt: -------------------------------------------------------------------------------- 1 | MiCasa Design -*- mode: outline -*- 2 | 3 | * Overview 4 | The MiCasa service is a combination of a game server and a client 5 | framework for hosting relatively simple, networked, multiplayer games. The 6 | service is designed for hosting games implemented using the Parlor 7 | services and built on top of the Presents networking platform. 8 | 9 | The MiCasa service is comprised of a server that can be configured to have 10 | any number of lobbies in which users can get together to play games. 11 | 12 | * Notes 13 | Maybe move lobby stuff into parlor. 14 | 15 | Move lobby configuration (which lobbies to load) into database. Make it so 16 | that lobbies can be created/destroyed on the fly. 17 | 18 | Sort out a different way for lobbies to get configuration information than 19 | being passed a properties file that was extracted from the server 20 | configuration. We'll want inheritance and all that. 21 | 22 | Make sure chat box remains focused for games where that's feasible... 23 | 24 | Logoff shouldn't be in same place as "Back to lobby" 25 | 26 | "Back to lobby" accidentally pressed when typing not in chat box... 27 | 28 | Chat box shouldn't allow blank submissions. 29 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/chat/data/TellFeedbackMessage.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.chat.data; 7 | 8 | import com.threerings.util.Name; 9 | 10 | /** 11 | * A feedback message to indicate that a tell succeeded. 12 | */ 13 | public class TellFeedbackMessage extends UserMessage 14 | { 15 | /** 16 | * A tell feedback message is only composed on the client. 17 | */ 18 | public TellFeedbackMessage (Name target, String message, boolean failure) 19 | { 20 | super(target, null, message, ChatCodes.DEFAULT_MODE); 21 | _failure = failure; 22 | } 23 | 24 | /** 25 | * Returns true if this is a failure feedback, false if it is successful tell feedback. 26 | */ 27 | public boolean isFailure () 28 | { 29 | return _failure; 30 | } 31 | 32 | @Override 33 | public String getFormat () 34 | { 35 | return _failure ? null : "m.told_format"; 36 | } 37 | 38 | protected boolean _failure; 39 | } 40 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/data/LocationCodes.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.data; 7 | 8 | import com.threerings.presents.data.InvocationCodes; 9 | 10 | /** 11 | * Contains codes used by the location invocation services. 12 | */ 13 | public interface LocationCodes extends InvocationCodes 14 | { 15 | /** An error code indicating that a place identified by a particular 16 | * place id does not exist. Usually generated by a failed moveTo 17 | * request. */ 18 | public static final String NO_SUCH_PLACE = "m.no_such_place"; 19 | 20 | /** An error code sent when a user requests to move to a new place but 21 | * they are in the middle of moving somewhere already. */ 22 | public static final String MOVE_IN_PROGRESS = "m.move_in_progress"; 23 | 24 | /** An error code sent when a user requests to move to a place, but 25 | * they are already in the requested place. */ 26 | public static final String ALREADY_THERE = "m.already_there"; 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/client/OccupantObserver.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.client; 7 | 8 | import com.threerings.crowd.data.OccupantInfo; 9 | 10 | /** 11 | * An entity that is interested in hearing about bodies that enter and leave a location (as well 12 | * as disconnect and reconnect) can implement this interface and register itself with the 13 | * {@link OccupantDirector}. 14 | */ 15 | public interface OccupantObserver 16 | { 17 | /** 18 | * Called when a body enters the place. 19 | */ 20 | void occupantEntered (OccupantInfo info); 21 | 22 | /** 23 | * Called when a body leaves the place. 24 | */ 25 | void occupantLeft (OccupantInfo info); 26 | 27 | /** 28 | * Called when an occupant is updated. 29 | * 30 | * @param oldinfo the occupant info prior to the update. 31 | * @param newinfo the newly update info record. 32 | */ 33 | void occupantUpdated (OccupantInfo oldinfo, OccupantInfo newinfo); 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/admin/data/ConfigObject.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.admin.data; 7 | 8 | import java.lang.reflect.Field; 9 | 10 | import javax.swing.JPanel; 11 | import com.threerings.presents.dobj.DObject; 12 | import com.threerings.presents.util.PresentsContext; 13 | 14 | import com.threerings.admin.client.AsStringFieldEditor; 15 | import com.threerings.admin.client.BooleanFieldEditor; 16 | 17 | /** 18 | * Base class for runtime config distributed objects. Used to allow 19 | * config objects to supply custom object editing UI. 20 | */ 21 | public class ConfigObject extends DObject 22 | { 23 | /** 24 | * Returns the editor panel for the specified field. 25 | */ 26 | public JPanel getEditor (PresentsContext ctx, Field field) 27 | { 28 | if (field.getType().equals(Boolean.TYPE)) { 29 | return new BooleanFieldEditor(ctx, field, this); 30 | } else { 31 | return new AsStringFieldEditor(ctx, field, this); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /core/src/test/java/com/threerings/presents/server/OMgrIntervalTest.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.server; 7 | 8 | import org.junit.Test; 9 | import static org.junit.Assert.*; 10 | 11 | /** 12 | * Tests our handling of auto-canceling intervals created by the omgr if they expire after it has 13 | * shutdown. 14 | */ 15 | public class OMgrIntervalTest extends PresentsTestBase 16 | { 17 | @Test public void testIntervals () 18 | { 19 | final PresentsDObjectMgr omgr = getInstance(PresentsDObjectMgr.class); 20 | 21 | omgr.newInterval(new Runnable () { 22 | public void run () { 23 | if (++_count > 1) { 24 | omgr.harshShutdown(); 25 | } 26 | } 27 | }).schedule(100, true); 28 | 29 | omgr.run(); 30 | 31 | try { 32 | Thread.sleep(500); 33 | } catch (Exception e) { 34 | } 35 | 36 | assertTrue(_count == 2); 37 | } 38 | 39 | protected int _count; 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/util/ConfirmAdapter.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.util; 7 | 8 | import com.samskivert.util.ResultListener; 9 | 10 | import com.threerings.presents.client.InvocationService; 11 | import com.threerings.presents.client.InvocationService.ConfirmListener; 12 | import com.threerings.presents.data.InvocationCodes; 13 | import com.threerings.presents.server.InvocationException; 14 | 15 | /** 16 | * Adapts the response from a {@link ResultListener} to a {@link ConfirmListener} if the failure is 17 | * an instance of {@link InvocationException} the message will be passed on to the confirm 18 | * listener, otherwise they will be provided with {@link InvocationCodes#INTERNAL_ERROR}. 19 | */ 20 | public class ConfirmAdapter extends IgnoreConfirmAdapter 21 | { 22 | /** 23 | * Creates an adapter with the supplied listener. 24 | */ 25 | public ConfirmAdapter (InvocationService.ConfirmListener listener) 26 | { 27 | super(listener); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/util/StreamableTuple.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.util; 7 | 8 | import com.samskivert.util.Tuple; 9 | 10 | import com.threerings.io.Streamable; 11 | 12 | /** 13 | * A {@link Tuple} extension that can be streamed. The contents of the tuple 14 | * must also be of streamable types. 15 | * 16 | * @see Streamable 17 | * @param the type of the left-hand side of this tuple. 18 | * @param the type of the right-hand side of this tuple. 19 | */ 20 | public class StreamableTuple extends Tuple 21 | implements Streamable 22 | { 23 | /** 24 | * Creates a tuple with the specified two objects. 25 | */ 26 | public static StreamableTuple newTuple (L left, R right) 27 | { 28 | return new StreamableTuple(left, right); 29 | } 30 | 31 | /** 32 | * Constructs a tuple with the two specified objects. 33 | */ 34 | public StreamableTuple (L left, R right) 35 | { 36 | super(left, right); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/java/com/threerings/presents/peer/server/TestPeerManager.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.peer.server; 7 | 8 | import com.google.inject.Inject; 9 | import com.google.inject.Singleton; 10 | 11 | import com.samskivert.util.Lifecycle; 12 | 13 | /** 14 | * A peer manager with hooks for testing. 15 | */ 16 | @Singleton 17 | public class TestPeerManager extends PeerManager 18 | { 19 | public interface Callback { 20 | void apply (T value); 21 | } 22 | 23 | @Inject 24 | public TestPeerManager (Lifecycle cycle) { 25 | super(cycle); 26 | } 27 | 28 | public void setOnConnected (Callback onConnected) { 29 | _onConnected = onConnected; 30 | } 31 | 32 | @Override 33 | protected void connectedToPeer (PeerNode peer) { 34 | super.connectedToPeer(peer); 35 | if (_onConnected != null) { 36 | _onConnected.apply(peer.nodeobj.nodeName); 37 | } 38 | } 39 | 40 | protected Callback _onConnected; 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/peer/client/CrowdPeerService.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.peer.client; 7 | 8 | import com.threerings.util.Name; 9 | 10 | import com.threerings.presents.client.InvocationService; 11 | import com.threerings.presents.data.ClientObject; 12 | 13 | import com.threerings.crowd.chat.client.ChatService; 14 | import com.threerings.crowd.chat.data.UserMessage; 15 | 16 | /** 17 | * Bridges certain Crowd services between peers in a cluster configuration. 18 | */ 19 | public interface CrowdPeerService extends InvocationService 20 | { 21 | /** 22 | * Used to forward a tell request to the server on which the destination user actually 23 | * occupies. 24 | */ 25 | void deliverTell (UserMessage message, Name target, 26 | ChatService.TellListener listener); 27 | 28 | /** 29 | * Dispatches a broadcast message on this peer. 30 | */ 31 | void deliverBroadcast (Name from, byte levelOrMode, String bundle, String msg); 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/io/SimpleStreamableObject.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.io; 7 | 8 | import com.samskivert.util.StringUtil; 9 | 10 | import com.threerings.util.ActionScript; 11 | 12 | /** 13 | * A simple serializable object implements the {@link Streamable} 14 | * interface and provides a default {@link Object#toString} implementation which 15 | * outputs all public members. 16 | */ 17 | public class SimpleStreamableObject implements Streamable 18 | { 19 | @Override 20 | public String toString () 21 | { 22 | StringBuilder buf = new StringBuilder("["); 23 | toString(buf); 24 | return buf.append("]").toString(); 25 | } 26 | 27 | /** 28 | * Handles the toString-ification of all public members. Derived 29 | * classes can override and include non-public members if desired. 30 | */ 31 | @ActionScript(name="toStringBuilder") 32 | protected void toString (StringBuilder buf) 33 | { 34 | StringUtil.fieldsToString(buf, this); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/net/UnsubscribeResponse.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.net; 7 | 8 | /** 9 | * Used to communicate to the client that we received their unsubscribe 10 | * request and that it is now OK to remove an object mapping from their 11 | * local object table. 12 | */ 13 | public class UnsubscribeResponse extends DownstreamMessage 14 | { 15 | /** 16 | * Zero argument constructor used when unserializing an instance. 17 | */ 18 | public UnsubscribeResponse () 19 | { 20 | super(); 21 | } 22 | 23 | /** 24 | * Constructs an unsubscribe response with the supplied oid. 25 | */ 26 | public UnsubscribeResponse (int oid) 27 | { 28 | _oid = oid; 29 | } 30 | 31 | public int getOid () 32 | { 33 | return _oid; 34 | } 35 | 36 | @Override 37 | public String toString () 38 | { 39 | return "[type=UNACK, msgid=" + messageId + ", oid=" + _oid + "]"; 40 | } 41 | 42 | protected int _oid; 43 | } 44 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/dobj/OidListListener.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.dobj; 7 | 8 | /** 9 | * Implemented by entities which wish to hear about changes that occur to oid list attributes of a 10 | * particular distributed object. 11 | * 12 | * @see DObject#addListener 13 | */ 14 | public interface OidListListener extends ChangeListener 15 | { 16 | /** 17 | * Called when an object added event has been dispatched on an object. This will be called 18 | * after the event has been applied to the object. 19 | * 20 | * @param event The event that was dispatched on the object. 21 | */ 22 | void objectAdded (ObjectAddedEvent event); 23 | 24 | /** 25 | * Called when an object removed event has been dispatched on an object. This will be called 26 | * after the event has been applied to the object. 27 | * 28 | * @param event The event that was dispatched on the object. 29 | */ 30 | void objectRemoved (ObjectRemovedEvent event); 31 | } 32 | -------------------------------------------------------------------------------- /tools/src/main/resources/com/threerings/presents/tools/marshaller_listener_as.tmpl: -------------------------------------------------------------------------------- 1 | package {{package}} { 2 | 3 | {{#importGroups}} 4 | {{#this}} 5 | import {{this}}; 6 | {{/this}} 7 | 8 | {{/importGroups}} 9 | /** 10 | * Marshalls instances of the {{name}}Service_{{listener.listenerName}}Marshaller interface. 11 | */ 12 | public class {{name}}Marshaller_{{listener.listenerName}}Marshaller 13 | extends InvocationMarshaller_ListenerMarshaller 14 | { 15 | {{#listener.methods}} 16 | /** The method id used to dispatch {{method.name}} responses. */ 17 | public static const {{code}} :int = {{-index}}; 18 | 19 | {{/listener.methods}} 20 | // from InvocationMarshaller_ListenerMarshaller 21 | override public function dispatchResponse (methodId :int, args :Array) :void 22 | { 23 | switch (methodId) { 24 | {{#listener.methods}} 25 | case {{code}}: 26 | (listener as {{name}}Service_{{listener.listenerName}}Listener).{{method.name}}( 27 | {{getASUnwrappedArgListAsListeners}}); 28 | return; 29 | 30 | {{/listener.methods}} 31 | default: 32 | super.dispatchResponse(methodId, args); 33 | return; 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /aslib/src/main/as/com/threerings/presents/data/Permission.as: -------------------------------------------------------------------------------- 1 | // 2 | // $Id$ 3 | // 4 | // Narya library - tools for developing networked games 5 | // Copyright (C) 2002-2012 Three Rings Design, Inc., All Rights Reserved 6 | // http://code.google.com/p/narya/ 7 | // 8 | // This library is free software; you can redistribute it and/or modify it 9 | // under the terms of the GNU Lesser General Public License as published 10 | // by the Free Software Foundation; either version 2.1 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This library is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | // Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public 19 | // License along with this library; if not, write to the Free Software 20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | package com.threerings.presents.data { 23 | 24 | /** 25 | * A value class used by ClientObject.checkAccess to do fine-grained access control. 26 | */ 27 | public class Permission 28 | { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /aslib/src/main/as/com/threerings/util/ResultListener.as: -------------------------------------------------------------------------------- 1 | // 2 | // $Id$ 3 | // 4 | // Narya library - tools for developing networked games 5 | // Copyright (C) 2002-2012 Three Rings Design, Inc., All Rights Reserved 6 | // http://code.google.com/p/narya/ 7 | // 8 | // This library is free software; you can redistribute it and/or modify it 9 | // under the terms of the GNU Lesser General Public License as published 10 | // by the Free Software Foundation; either version 2.1 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This library is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | // Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public 19 | // License along with this library; if not, write to the Free Software 20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | package com.threerings.util { 23 | 24 | public interface ResultListener 25 | { 26 | function requestCompleted (obj :Object) :void; 27 | 28 | function requestFailed (cause :Error) :void; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/server/LocationProvider.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.server; 7 | 8 | import javax.annotation.Generated; 9 | 10 | import com.threerings.presents.data.ClientObject; 11 | import com.threerings.presents.server.InvocationException; 12 | import com.threerings.presents.server.InvocationProvider; 13 | 14 | import com.threerings.crowd.client.LocationService; 15 | 16 | /** 17 | * Defines the server-side of the {@link LocationService}. 18 | */ 19 | @Generated(value={"com.threerings.presents.tools.GenServiceTask"}, 20 | comments="Derived from LocationService.java.") 21 | public interface LocationProvider extends InvocationProvider 22 | { 23 | /** 24 | * Handles a {@link LocationService#leavePlace} request. 25 | */ 26 | void leavePlace (ClientObject caller); 27 | 28 | /** 29 | * Handles a {@link LocationService#moveTo} request. 30 | */ 31 | void moveTo (ClientObject caller, int arg1, LocationService.MoveListener arg2) 32 | throws InvocationException; 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/dobj/ServerMessageEvent.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.dobj; 7 | 8 | /** 9 | * A message event that only goes to the server. If generated on the server then it never leaves 10 | * the server. 11 | */ 12 | public class ServerMessageEvent extends MessageEvent 13 | { 14 | /** 15 | * Constructs a new message event on the specified target object with the supplied name and 16 | * arguments. 17 | * 18 | * @param targetOid the object id of the object whose attribute has changed. 19 | * @param name the name of the message event. 20 | * @param args the arguments for this message. This array should contain only values of valid 21 | * distributed object types. 22 | */ 23 | public ServerMessageEvent (int targetOid, String name, Object[] args) 24 | { 25 | super(targetOid, name, args); 26 | } 27 | 28 | @Override 29 | public boolean isPrivate () 30 | { 31 | // this is what makes us server-only 32 | return true; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/util/ResultListenerList.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.util; 7 | 8 | import java.util.ArrayList; 9 | 10 | import com.threerings.presents.client.InvocationService; 11 | 12 | /** 13 | * Maintains a list of result listeners, dispatching the eventual actual result or failure to them 14 | * all as if they were a single listener. 15 | */ 16 | public class ResultListenerList extends ArrayList 17 | implements InvocationService.ResultListener 18 | { 19 | // from InvocationService.ResultListener 20 | public void requestProcessed (Object result) 21 | { 22 | for (InvocationService.ResultListener listener : this) { 23 | listener.requestProcessed(result); 24 | } 25 | } 26 | 27 | // from InvocationService.ResultListener 28 | public void requestFailed (String cause) 29 | { 30 | for (InvocationService.ResultListener listener : this) { 31 | listener.requestFailed(cause); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /aslib/src/main/as/com/threerings/crowd/client/MoveVetoedError.as: -------------------------------------------------------------------------------- 1 | // 2 | // $Id$ 3 | // 4 | // Narya library - tools for developing networked games 5 | // Copyright (C) 2002-2012 Three Rings Design, Inc., All Rights Reserved 6 | // http://code.google.com/p/narya/ 7 | // 8 | // This library is free software; you can redistribute it and/or modify it 9 | // under the terms of the GNU Lesser General Public License as published 10 | // by the Free Software Foundation; either version 2.1 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This library is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | // Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public 19 | // License along with this library; if not, write to the Free Software 20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | package com.threerings.crowd.client { 23 | 24 | /** 25 | * An exception that indicates that a LocationObserver vetoed our move request. 26 | */ 27 | public class MoveVetoedError extends Error 28 | { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/chat/client/SpeakService.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.chat.client; 7 | 8 | import com.threerings.presents.client.InvocationService; 9 | import com.threerings.presents.data.ClientObject; 10 | 11 | /** 12 | * Provides a means by which "speaking" can be allowed among subscribers 13 | * of a particular distributed object. 14 | */ 15 | public interface SpeakService extends InvocationService 16 | { 17 | /** 18 | * Issues a request to speak "on" the distributed object via which 19 | * this speak service was provided. 20 | * 21 | * @param message the message to be spoken. 22 | * @param mode the "mode" of the message. This is an opaque value that 23 | * will be passed back down via the {@link ChatDirector} to the {@link 24 | * ChatDisplay} implementations which can interpret it in an 25 | * application specific manner. It's useful for differentiating 26 | * between regular speech, emotes, etc. 27 | */ 28 | void speak (String message, byte mode); 29 | } 30 | -------------------------------------------------------------------------------- /cpplib/src/presents/ObjectInputStream.h: -------------------------------------------------------------------------------- 1 | // 2 | // $Id$ 3 | 4 | #pragma once 5 | 6 | #include "ClassMapping.h" 7 | #include "Streamer.h" 8 | 9 | namespace presents { class InputStream; } 10 | 11 | using namespace presents; 12 | 13 | class ObjectInputStream 14 | { 15 | public: 16 | ObjectInputStream (presents::InputStream* stream) : _in(stream), _classMap(1) { } 17 | 18 | bool readBoolean (); 19 | int8 readByte (); 20 | int16 readShort (); 21 | int32 readInt (); 22 | int64 readLong (); 23 | void readBytes (uint8* bytes, size_t length); 24 | float readFloat (); 25 | double readDouble (); 26 | utf8 readUTF (); 27 | 28 | Shared readObject (); 29 | 30 | template 31 | Shared readField () 32 | { 33 | return boost::static_pointer_cast(readField(getJavaName((const T*)NULL))); 34 | } 35 | 36 | Shared readField (utf8 javaname) 37 | { 38 | if (readBoolean()) { 39 | return getStreamer(javaname)->createObject(*this); 40 | } else { 41 | return Shared(); 42 | } 43 | } 44 | 45 | protected: 46 | presents::InputStream* _in; 47 | typedef std::vector ClassMap; 48 | ClassMap _classMap; 49 | }; 50 | -------------------------------------------------------------------------------- /cpplib/src/presents/streamers/StreamableStreamer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "presents/Streamer.h" 4 | #include "presents/Streamable.h" 5 | 6 | template 7 | class StreamableStreamer : public Streamer 8 | { 9 | public: 10 | Shared createObject (ObjectInputStream& in) 11 | { 12 | Shared streamable(new T()); 13 | streamable->readObject(in); 14 | return streamable; 15 | } 16 | 17 | void writeObject (const Shared& object, ObjectOutputStream& out) 18 | { 19 | ((Shared&)object)->writeObject(out); 20 | } 21 | }; 22 | 23 | #define DECLARE_STREAMABLE() \ 24 | static const utf8& javaName (); \ 25 | static void registerWithPresents () { javaName(); } \ 26 | virtual const utf8& getJavaClassName () const { return javaName(); } 27 | 28 | #define DEFINE_STREAMABLE(nameString, StreamableClass) \ 29 | static const utf8& gStreamableClassRegistration = StreamableClass::javaName(); \ 30 | const utf8& StreamableClass::javaName () {\ 31 | static const utf8 JAVA_NAME = nameString; \ 32 | static bool gRegistered = false; \ 33 | if (!gRegistered) { registerStreamer(JAVA_NAME, new StreamableStreamer()); gRegistered = true; } \ 34 | return JAVA_NAME; } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/chat/data/ChatChannel.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.chat.data; 7 | 8 | import com.threerings.io.SimpleStreamableObject; 9 | 10 | import com.threerings.presents.dobj.DSet; 11 | 12 | /** 13 | * Represents a chat channel. 14 | */ 15 | public abstract class ChatChannel extends SimpleStreamableObject 16 | implements Comparable, DSet.Entry 17 | { 18 | // from interface Comparable 19 | public abstract int compareTo (ChatChannel other); 20 | 21 | /** 22 | * Converts this channel into a unique name that can be used as the name of the distributed 23 | * lock used when resolving the channel. 24 | */ 25 | public abstract String getLockName (); 26 | 27 | // from interface DSet.Entry 28 | public Comparable getKey () 29 | { 30 | return this; 31 | } 32 | 33 | @Override 34 | public boolean equals (Object other) 35 | { 36 | return compareTo((ChatChannel)other) == 0; 37 | } 38 | 39 | @Override 40 | public abstract int hashCode (); 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/chat/data/UserSystemMessage.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.chat.data; 7 | 8 | import com.threerings.util.Name; 9 | 10 | /** 11 | * A system message triggered by the activity of another user. If the user is muted we can suppress 12 | * this message, unlike a normal system message. 13 | */ 14 | public class UserSystemMessage extends SystemMessage 15 | { 16 | /** The "speaker" of this message, the user that triggered that this message be sent to us. */ 17 | public Name speaker; 18 | 19 | /** 20 | * Construct a INFO-level UserSystemMessage. 21 | */ 22 | public static UserSystemMessage create (Name sender, String message, String bundle) 23 | { 24 | return new UserSystemMessage(sender, message, bundle, INFO); 25 | } 26 | 27 | /** 28 | * Construct a UserSystemMessage. 29 | */ 30 | public UserSystemMessage (Name sender, String message, String bundle, byte attentionLevel) 31 | { 32 | super(message, bundle, attentionLevel); 33 | this.speaker = sender; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /aslib/src/main/as/com/threerings/util/Boxed.as: -------------------------------------------------------------------------------- 1 | // 2 | // $Id$ 3 | // 4 | // Narya library - tools for developing networked games 5 | // Copyright (C) 2002-2012 Three Rings Design, Inc., All Rights Reserved 6 | // http://code.google.com/p/narya/ 7 | // 8 | // This library is free software; you can redistribute it and/or modify it 9 | // under the terms of the GNU Lesser General Public License as published 10 | // by the Free Software Foundation; either version 2.1 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This library is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | // Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public 19 | // License along with this library; if not, write to the Free Software 20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | package com.threerings.util { 23 | 24 | /** 25 | * An interface implemented by our "boxed" data classes. 26 | */ 27 | public interface Boxed 28 | { 29 | /** 30 | * Return the unboxed value. 31 | */ 32 | function unbox () :Object; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tools/src/main/java/com/threerings/presents/tools/KeyPairGen.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.tools; 7 | 8 | import java.security.KeyPair; 9 | 10 | import com.threerings.presents.util.SecureUtil; 11 | 12 | /** 13 | * Generates a RSA public/private key pair and outputs them in a format suitable for a properties 14 | * file. 15 | */ 16 | public class KeyPairGen 17 | { 18 | public static void main (String[] args) 19 | { 20 | if (args.length != 1) { 21 | System.err.println("Usage: KeyPairGen bits"); 22 | System.exit(-1); 23 | } 24 | 25 | try { 26 | int bits = Integer.parseInt(args[0]); 27 | KeyPair kp = SecureUtil.genRSAKeyPair(bits); 28 | System.out.println("key.public = " + SecureUtil.RSAKeyToString(kp.getPublic())); 29 | System.out.println("key.private = " + SecureUtil.RSAKeyToString(kp.getPrivate())); 30 | } catch (NumberFormatException nfe) { 31 | System.err.println("Usage: KeyPairGen bits"); 32 | System.exit(-1); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /aslib/src/main/as/com/threerings/presents/net/LogoffRequest.as: -------------------------------------------------------------------------------- 1 | // 2 | // $Id$ 3 | // 4 | // Narya library - tools for developing networked games 5 | // Copyright (C) 2002-2012 Three Rings Design, Inc., All Rights Reserved 6 | // http://code.google.com/p/narya/ 7 | // 8 | // This library is free software; you can redistribute it and/or modify it 9 | // under the terms of the GNU Lesser General Public License as published 10 | // by the Free Software Foundation; either version 2.1 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This library is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | // Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public 19 | // License along with this library; if not, write to the Free Software 20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | package com.threerings.presents.net { 23 | 24 | public class LogoffRequest extends UpstreamMessage 25 | { 26 | public function toString () :String 27 | { 28 | return "[type=LOGOFF, msgid=" + messageId + "]"; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /docs/media/design.txt: -------------------------------------------------------------------------------- 1 | Media Design Notes -*- mode: outline -*- 2 | 3 | * Tile system 4 | ** Classes 5 | Tile 6 | TileSet 7 | 8 | TileManager 9 | TileSetRepository 10 | 11 | TileSetIDBroker 12 | 13 | XMLTileSetParser 14 | 15 | TileSetBundle 16 | BundledTileSetRepository 17 | TileSetBundler 18 | 19 | ** Tile management 20 | Managing tilesets by id involves creating tileset bundles from XML tileset 21 | descriptions. 22 | 23 | Tileset bundles contain both the tileset images and the tileset metadata 24 | (in the form of serialized tileset classes?) 25 | 26 | Tileset bundle creation maintains a stable tileset name to tileset id 27 | mapping through the use of a TileSetIDBroker which maintains the name to 28 | id mapping (in a database or however it likes) 29 | 30 | Sample tileset XML description (for uniform tiles): 31 | 32 | 33 | foo/bar/tiles.png 34 | 64 35 | 48 36 | 16 37 | 38 | 39 | * 01/07/2003 40 | ** Image management refactor 41 | x TileSet:ImageProvider needs to provide colorized images 42 | ! Probably give tilesets the ImageManager since they have to give the 43 | ImageManager reference to the Tile so that it can lock its colorized 44 | source image 45 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/crowd/client/LocationAdapter.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.crowd.client; 7 | 8 | import com.threerings.crowd.data.PlaceObject; 9 | 10 | /** 11 | * The location adapter makes life easier for a class that really only 12 | * cares about one or two of the location observer callbacks and doesn't 13 | * want to provide empty implementations of the others. One can either 14 | * extend location adapter, or create an anonymous instance that overrides 15 | * the desired callback(s). Note that the location adapter defaults to 16 | * ratifying any location change. 17 | * 18 | * @see LocationObserver 19 | */ 20 | public class LocationAdapter implements LocationObserver 21 | { 22 | // documentation inherited 23 | public boolean locationMayChange (int placeId) 24 | { 25 | return true; 26 | } 27 | 28 | // documentation inherited 29 | public void locationDidChange (PlaceObject place) 30 | { 31 | } 32 | 33 | // documentation inherited 34 | public void locationChangeFailed (int placeId, String reason) 35 | { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /aslib/src/main/as/com/threerings/presents/net/Credentials_HasLanguage.as: -------------------------------------------------------------------------------- 1 | // 2 | // $Id$ 3 | // 4 | // Narya library - tools for developing networked games 5 | // Copyright (C) 2002-2012 Three Rings Design, Inc., All Rights Reserved 6 | // http://code.google.com/p/narya/ 7 | // 8 | // This library is free software; you can redistribute it and/or modify it 9 | // under the terms of the GNU Lesser General Public License as published 10 | // by the Free Software Foundation; either version 2.1 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This library is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | // Lesser General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU Lesser General Public 19 | // License along with this library; if not, write to the Free Software 20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | package com.threerings.presents.net { 23 | 24 | /** 25 | * Implemented by credentials that provide a language. On the client this is just a marker 26 | * interface, for now. 27 | */ 28 | public interface Credentials_HasLanguage 29 | { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/com/threerings/presents/net/FailureResponse.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.net; 7 | 8 | /** 9 | * Communicates failure to subscribe to an object. 10 | */ 11 | public class FailureResponse extends DownstreamMessage 12 | { 13 | /** 14 | * Zero argument constructor used when unserializing an instance. 15 | */ 16 | public FailureResponse () 17 | { 18 | super(); 19 | } 20 | 21 | /** 22 | * Constructs a failure response in response to a request for the specified oid. 23 | */ 24 | public FailureResponse (int oid, String message) 25 | { 26 | _oid = oid; 27 | _message = message; 28 | } 29 | 30 | public int getOid () 31 | { 32 | return _oid; 33 | } 34 | 35 | public String getMessage () 36 | { 37 | return _message; 38 | } 39 | 40 | @Override 41 | public String toString () 42 | { 43 | return "[type=FAIL, msgid=" + messageId + ", oid=" + _oid + ", msg=" + _message + "]"; 44 | } 45 | 46 | protected int _oid; 47 | protected String _message; 48 | } 49 | -------------------------------------------------------------------------------- /tools/src/main/java/com/threerings/presents/tools/StreamableClassRequirements.java: -------------------------------------------------------------------------------- 1 | // 2 | // Narya library - tools for developing networked games 3 | // Copyright (C) 2002-2025 Three Rings Design, Inc., All Rights Reserved 4 | // https://github.com/threerings/narya/blob/master/LICENSE 5 | 6 | package com.threerings.presents.tools; 7 | 8 | import java.lang.reflect.Field; 9 | import java.lang.reflect.Modifier; 10 | 11 | import java.util.List; 12 | 13 | import com.google.common.collect.Lists; 14 | 15 | import com.threerings.io.Streamable; 16 | 17 | public class StreamableClassRequirements 18 | { 19 | public final List streamedFields = Lists.newArrayList(); 20 | 21 | public final boolean superclassStreamable; 22 | 23 | public final Class klass; 24 | 25 | public StreamableClassRequirements(Class klass) 26 | { 27 | this.klass = klass; 28 | superclassStreamable = 29 | klass.getSuperclass() != null && Streamable.class.isAssignableFrom(klass.getSuperclass()); 30 | for (Field field : klass.getDeclaredFields()) { 31 | int mods = field.getModifiers(); 32 | if (Modifier.isStatic(mods) || Modifier.isTransient(mods)) { 33 | continue; 34 | } 35 | streamedFields.add(field); 36 | } 37 | } 38 | } 39 | --------------------------------------------------------------------------------