Convert Narya (most of the way) over to a Maven Ant task based build. The
ActionScript bits remain belligerent, but the Java stuff is mostly shipshape. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6222 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.presents.peer.data;
|
||||
|
||||
import com.threerings.io.SimpleStreamableObject;
|
||||
|
||||
import com.threerings.util.Name;
|
||||
|
||||
import com.threerings.presents.dobj.DSet;
|
||||
|
||||
/**
|
||||
* Contains information on a particular client.
|
||||
*/
|
||||
public class ClientInfo extends SimpleStreamableObject
|
||||
implements DSet.Entry
|
||||
{
|
||||
/** The username used by this client to authenticate. */
|
||||
public Name username;
|
||||
|
||||
// documentation inherited from interface DSet.Entry
|
||||
public Comparable<?> getKey ()
|
||||
{
|
||||
return username;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,372 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.presents.peer.data;
|
||||
|
||||
import javax.annotation.Generated;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import com.threerings.io.SimpleStreamableObject;
|
||||
import com.threerings.io.Streamable;
|
||||
|
||||
import com.threerings.presents.dobj.DObject;
|
||||
import com.threerings.presents.dobj.DSet;
|
||||
|
||||
/**
|
||||
* Contains information that one node published for all of its peers.
|
||||
*/
|
||||
public class NodeObject extends DObject
|
||||
{
|
||||
// AUTO-GENERATED: FIELDS START
|
||||
/** The field name of the <code>nodeName</code> field. */
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public static final String NODE_NAME = "nodeName";
|
||||
|
||||
/** The field name of the <code>bootStamp</code> field. */
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public static final String BOOT_STAMP = "bootStamp";
|
||||
|
||||
/** The field name of the <code>peerService</code> field. */
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public static final String PEER_SERVICE = "peerService";
|
||||
|
||||
/** The field name of the <code>clients</code> field. */
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public static final String CLIENTS = "clients";
|
||||
|
||||
/** The field name of the <code>locks</code> field. */
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public static final String LOCKS = "locks";
|
||||
|
||||
/** The field name of the <code>acquiringLock</code> field. */
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public static final String ACQUIRING_LOCK = "acquiringLock";
|
||||
|
||||
/** The field name of the <code>releasingLock</code> field. */
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public static final String RELEASING_LOCK = "releasingLock";
|
||||
|
||||
/** The field name of the <code>cacheData</code> field. */
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public static final String CACHE_DATA = "cacheData";
|
||||
// AUTO-GENERATED: FIELDS END
|
||||
|
||||
/** Identifies a locked resource. */
|
||||
public static class Lock extends SimpleStreamableObject
|
||||
implements Comparable<Lock>, DSet.Entry
|
||||
{
|
||||
/** The resource type. Only resources of the same type will have their ids compared. */
|
||||
public String type;
|
||||
|
||||
/** The resource identifier, which can be <code>null</code> for singleton resources. */
|
||||
public Comparable<?> id;
|
||||
|
||||
public Lock ()
|
||||
{
|
||||
}
|
||||
|
||||
public Lock (String type, Comparable<?> id)
|
||||
{
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
// documentation inherited from interface Comparable
|
||||
public int compareTo (Lock olock)
|
||||
{
|
||||
int v1 = type.compareTo(olock.type);
|
||||
if (v1 != 0 || id == null) {
|
||||
return v1;
|
||||
}
|
||||
return DSet.compare(id, olock.id);
|
||||
}
|
||||
|
||||
// documentation inherited from interface DSet.Entry
|
||||
public Comparable<?> getKey ()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode ()
|
||||
{
|
||||
return type.hashCode() + (id == null ? 0 : id.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals (Object other)
|
||||
{
|
||||
Lock olock = (Lock)other;
|
||||
return type.equals(olock.type) && Objects.equal(id, olock.id);
|
||||
}
|
||||
}
|
||||
|
||||
/** Used for informing peers of changes to persistent data. */
|
||||
public static class CacheData extends SimpleStreamableObject
|
||||
{
|
||||
/** The cache that should be purged. */
|
||||
public String cache;
|
||||
|
||||
/** The stale data in the cache. */
|
||||
public Streamable data;
|
||||
|
||||
public CacheData ()
|
||||
{
|
||||
}
|
||||
|
||||
public CacheData (String cache, Streamable data)
|
||||
{
|
||||
this.cache = cache;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
||||
/** The node name of this peer. */
|
||||
public String nodeName;
|
||||
|
||||
/** The time that this node's JVM started up. */
|
||||
public long bootStamp;
|
||||
|
||||
/** The service used to make requests of the node. */
|
||||
public PeerMarshaller peerService;
|
||||
|
||||
/** Contains information on all clients connected to this node. */
|
||||
public DSet<ClientInfo> clients = new DSet<ClientInfo>();
|
||||
|
||||
/** The set of locks held by this node. */
|
||||
public DSet<Lock> locks = new DSet<Lock>();
|
||||
|
||||
/** Used to broadcast a node's desire to acquire a lock. */
|
||||
public Lock acquiringLock;
|
||||
|
||||
/** Used to broadcast a node's desire to release a lock. */
|
||||
public Lock releasingLock;
|
||||
|
||||
/** A field we use to broadcast changes to possible cached data. */
|
||||
public CacheData cacheData;
|
||||
|
||||
// AUTO-GENERATED: METHODS START
|
||||
/**
|
||||
* Requests that the <code>nodeName</code> field be set to the
|
||||
* specified value. The local value will be updated immediately and an
|
||||
* event will be propagated through the system to notify all listeners
|
||||
* that the attribute did change. Proxied copies of this object (on
|
||||
* clients) will apply the value change when they received the
|
||||
* attribute changed notification.
|
||||
*/
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public void setNodeName (String value)
|
||||
{
|
||||
String ovalue = this.nodeName;
|
||||
requestAttributeChange(
|
||||
NODE_NAME, value, ovalue);
|
||||
this.nodeName = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>bootStamp</code> field be set to the
|
||||
* specified value. The local value will be updated immediately and an
|
||||
* event will be propagated through the system to notify all listeners
|
||||
* that the attribute did change. Proxied copies of this object (on
|
||||
* clients) will apply the value change when they received the
|
||||
* attribute changed notification.
|
||||
*/
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public void setBootStamp (long value)
|
||||
{
|
||||
long ovalue = this.bootStamp;
|
||||
requestAttributeChange(
|
||||
BOOT_STAMP, Long.valueOf(value), Long.valueOf(ovalue));
|
||||
this.bootStamp = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>peerService</code> field be set to the
|
||||
* specified value. The local value will be updated immediately and an
|
||||
* event will be propagated through the system to notify all listeners
|
||||
* that the attribute did change. Proxied copies of this object (on
|
||||
* clients) will apply the value change when they received the
|
||||
* attribute changed notification.
|
||||
*/
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public void setPeerService (PeerMarshaller value)
|
||||
{
|
||||
PeerMarshaller ovalue = this.peerService;
|
||||
requestAttributeChange(
|
||||
PEER_SERVICE, value, ovalue);
|
||||
this.peerService = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the specified entry be added to the
|
||||
* <code>clients</code> set. The set will not change until the event is
|
||||
* actually propagated through the system.
|
||||
*/
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public void addToClients (ClientInfo elem)
|
||||
{
|
||||
requestEntryAdd(CLIENTS, clients, elem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the entry matching the supplied key be removed from
|
||||
* the <code>clients</code> set. The set will not change until the
|
||||
* event is actually propagated through the system.
|
||||
*/
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public void removeFromClients (Comparable<?> key)
|
||||
{
|
||||
requestEntryRemove(CLIENTS, clients, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the specified entry be updated in the
|
||||
* <code>clients</code> set. The set will not change until the event is
|
||||
* actually propagated through the system.
|
||||
*/
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public void updateClients (ClientInfo elem)
|
||||
{
|
||||
requestEntryUpdate(CLIENTS, clients, elem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>clients</code> field be set to the
|
||||
* specified value. Generally one only adds, updates and removes
|
||||
* entries of a distributed set, but certain situations call for a
|
||||
* complete replacement of the set value. The local value will be
|
||||
* updated immediately and an event will be propagated through the
|
||||
* system to notify all listeners that the attribute did
|
||||
* change. Proxied copies of this object (on clients) will apply the
|
||||
* value change when they received the attribute changed notification.
|
||||
*/
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public void setClients (DSet<ClientInfo> value)
|
||||
{
|
||||
requestAttributeChange(CLIENTS, value, this.clients);
|
||||
DSet<ClientInfo> clone = (value == null) ? null : value.clone();
|
||||
this.clients = clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the specified entry be added to the
|
||||
* <code>locks</code> set. The set will not change until the event is
|
||||
* actually propagated through the system.
|
||||
*/
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public void addToLocks (NodeObject.Lock elem)
|
||||
{
|
||||
requestEntryAdd(LOCKS, locks, elem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the entry matching the supplied key be removed from
|
||||
* the <code>locks</code> set. The set will not change until the
|
||||
* event is actually propagated through the system.
|
||||
*/
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public void removeFromLocks (Comparable<?> key)
|
||||
{
|
||||
requestEntryRemove(LOCKS, locks, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the specified entry be updated in the
|
||||
* <code>locks</code> set. The set will not change until the event is
|
||||
* actually propagated through the system.
|
||||
*/
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public void updateLocks (NodeObject.Lock elem)
|
||||
{
|
||||
requestEntryUpdate(LOCKS, locks, elem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>locks</code> field be set to the
|
||||
* specified value. Generally one only adds, updates and removes
|
||||
* entries of a distributed set, but certain situations call for a
|
||||
* complete replacement of the set value. The local value will be
|
||||
* updated immediately and an event will be propagated through the
|
||||
* system to notify all listeners that the attribute did
|
||||
* change. Proxied copies of this object (on clients) will apply the
|
||||
* value change when they received the attribute changed notification.
|
||||
*/
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public void setLocks (DSet<NodeObject.Lock> value)
|
||||
{
|
||||
requestAttributeChange(LOCKS, value, this.locks);
|
||||
DSet<NodeObject.Lock> clone = (value == null) ? null : value.clone();
|
||||
this.locks = clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>acquiringLock</code> field be set to the
|
||||
* specified value. The local value will be updated immediately and an
|
||||
* event will be propagated through the system to notify all listeners
|
||||
* that the attribute did change. Proxied copies of this object (on
|
||||
* clients) will apply the value change when they received the
|
||||
* attribute changed notification.
|
||||
*/
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public void setAcquiringLock (NodeObject.Lock value)
|
||||
{
|
||||
NodeObject.Lock ovalue = this.acquiringLock;
|
||||
requestAttributeChange(
|
||||
ACQUIRING_LOCK, value, ovalue);
|
||||
this.acquiringLock = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>releasingLock</code> field be set to the
|
||||
* specified value. The local value will be updated immediately and an
|
||||
* event will be propagated through the system to notify all listeners
|
||||
* that the attribute did change. Proxied copies of this object (on
|
||||
* clients) will apply the value change when they received the
|
||||
* attribute changed notification.
|
||||
*/
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public void setReleasingLock (NodeObject.Lock value)
|
||||
{
|
||||
NodeObject.Lock ovalue = this.releasingLock;
|
||||
requestAttributeChange(
|
||||
RELEASING_LOCK, value, ovalue);
|
||||
this.releasingLock = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the <code>cacheData</code> field be set to the
|
||||
* specified value. The local value will be updated immediately and an
|
||||
* event will be propagated through the system to notify all listeners
|
||||
* that the attribute did change. Proxied copies of this object (on
|
||||
* clients) will apply the value change when they received the
|
||||
* attribute changed notification.
|
||||
*/
|
||||
@Generated(value={"com.threerings.presents.tools.GenDObjectTask"})
|
||||
public void setCacheData (NodeObject.CacheData value)
|
||||
{
|
||||
NodeObject.CacheData ovalue = this.cacheData;
|
||||
requestAttributeChange(
|
||||
CACHE_DATA, value, ovalue);
|
||||
this.cacheData = value;
|
||||
}
|
||||
// AUTO-GENERATED: METHODS END
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.presents.peer.data;
|
||||
|
||||
import com.threerings.util.Name;
|
||||
|
||||
/**
|
||||
* Represents an authenticated peer client.
|
||||
*/
|
||||
public class PeerAuthName extends Name
|
||||
{
|
||||
public PeerAuthName (String nodeName)
|
||||
{
|
||||
super(nodeName);
|
||||
}
|
||||
|
||||
// used when unserializing
|
||||
public PeerAuthName ()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
|
||||
// http://code.google.com/p/narya/
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published
|
||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package com.threerings.presents.peer.data;
|
||||
|
||||
import javax.annotation.Generated;
|
||||
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.InvocationService;
|
||||
import com.threerings.presents.data.InvocationMarshaller;
|
||||
import com.threerings.presents.peer.client.PeerService;
|
||||
|
||||
/**
|
||||
* Provides the implementation of the {@link PeerService} interface
|
||||
* that marshalls the arguments and delivers the request to the provider
|
||||
* on the server. Also provides an implementation of the response listener
|
||||
* interfaces that marshall the response arguments and deliver them back
|
||||
* to the requesting client.
|
||||
*/
|
||||
@Generated(value={"com.threerings.presents.tools.GenServiceTask"},
|
||||
comments="Derived from PeerService.java.")
|
||||
public class PeerMarshaller extends InvocationMarshaller
|
||||
implements PeerService
|
||||
{
|
||||
/** The method id used to dispatch {@link #generateReport} requests. */
|
||||
public static final int GENERATE_REPORT = 1;
|
||||
|
||||
// from interface PeerService
|
||||
public void generateReport (Client arg1, String arg2, InvocationService.ResultListener arg3)
|
||||
{
|
||||
InvocationMarshaller.ResultMarshaller listener3 = new InvocationMarshaller.ResultMarshaller();
|
||||
listener3.listener = arg3;
|
||||
sendRequest(arg1, GENERATE_REPORT, new Object[] {
|
||||
arg2, listener3
|
||||
});
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #invokeAction} requests. */
|
||||
public static final int INVOKE_ACTION = 2;
|
||||
|
||||
// from interface PeerService
|
||||
public void invokeAction (Client arg1, byte[] arg2)
|
||||
{
|
||||
sendRequest(arg1, INVOKE_ACTION, new Object[] {
|
||||
arg2
|
||||
});
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #invokeRequest} requests. */
|
||||
public static final int INVOKE_REQUEST = 3;
|
||||
|
||||
// from interface PeerService
|
||||
public void invokeRequest (Client arg1, byte[] arg2, InvocationService.ResultListener arg3)
|
||||
{
|
||||
InvocationMarshaller.ResultMarshaller listener3 = new InvocationMarshaller.ResultMarshaller();
|
||||
listener3.listener = arg3;
|
||||
sendRequest(arg1, INVOKE_REQUEST, new Object[] {
|
||||
arg2, listener3
|
||||
});
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #ratifyLockAction} requests. */
|
||||
public static final int RATIFY_LOCK_ACTION = 4;
|
||||
|
||||
// from interface PeerService
|
||||
public void ratifyLockAction (Client arg1, NodeObject.Lock arg2, boolean arg3)
|
||||
{
|
||||
sendRequest(arg1, RATIFY_LOCK_ACTION, new Object[] {
|
||||
arg2, Boolean.valueOf(arg3)
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user