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 |
--------------------------------------------------------------------------------