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:
Michael Bayne
2010-10-22 21:12:29 +00:00
parent 555b865bbf
commit 9d2ca42eac
434 changed files with 163 additions and 208 deletions
@@ -0,0 +1,119 @@
//
// $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.net;
import java.util.TimeZone;
import java.io.IOException;
import com.threerings.io.ObjectInputStream;
/**
* Used to authenticate with the server.
*/
public class AuthRequest extends UpstreamMessage
{
/**
* Zero argument constructor used when unserializing an instance.
*/
public AuthRequest ()
{
super();
}
/**
* Constructs a auth request with the supplied credentials and client version information.
*/
public AuthRequest (Credentials creds, String version, String[] bootGroups)
{
_creds = creds;
_version = version;
_zone = TimeZone.getDefault().getID();
_bootGroups = bootGroups;
}
/**
* Returns a reference to the credentials provided with this request.
*/
public Credentials getCredentials ()
{
return _creds;
}
/**
* Returns a reference to the version information provided with this request.
*/
public String getVersion ()
{
return _version;
}
/**
* Returns the timezone in which this client is operating.
*/
public TimeZone getTimeZone ()
{
return TimeZone.getTimeZone(_zone);
}
/**
* Returns the set of bootstrap service groups in which this client is interested.
*/
public String[] getBootGroups ()
{
return _bootGroups;
}
@Override
public String toString ()
{
return "[type=AREQ, msgid=" + messageId + ", creds=" + _creds +
", version=" + _version + "]";
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
try {
in.defaultReadObject();
} catch (IOException ioe) {
// if we fail here because the client is old, leave ourselves with a partially
// initialized set of credentials, which the server will generally cope with by telling
// the client it is out of date
}
}
/** The credentials associated with this auth request. */
protected Credentials _creds;
/** The version information associated with the client code. */
protected String _version;
/** The timezone in which this client is operating. */
protected String _zone;
/** The set of bootstrap service groups this client is interested in. */
protected String[] _bootGroups;
}
@@ -0,0 +1,76 @@
//
// $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.net;
/**
* The auth response communicates authentication success or failure as
* well as associated information via a distribted object transmitted
* along with the response. The distributed object simply serves as a
* container for the varied and manifold data involved in the
* authentication process.
*/
public class AuthResponse extends DownstreamMessage
{
/** Auxilliary authentication data to be communicated to the <code>
* PresentsSession</code> once a session is started. This is a means by
* which the <code>Authenticator</code> can pass information loaded from,
* say, an authentication database into the runtime system to be used, for
* example for permissions. */
public transient Object authdata;
/**
* Zero argument constructor used when unserializing an instance.
*/
public AuthResponse ()
{
super();
}
/**
* Constructs a auth response with the supplied response data.
*/
public AuthResponse (AuthResponseData data)
{
_data = data;
}
public AuthResponseData getData ()
{
return _data;
}
/**
* Replaces this response's auth data.
*/
public void setData (AuthResponseData data)
{
_data = data;
}
@Override
public String toString ()
{
return "[type=ARSP, msgid=" + messageId + ", data=" + _data + "]";
}
protected AuthResponseData _data;
}
@@ -0,0 +1,42 @@
//
// $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.net;
import com.threerings.presents.dobj.DObject;
/**
* An <code>AuthResponseData</code> object is communicated back to the
* client along with an authentication response. It contains an indicator
* of authentication success or failure along with bootstrap information
* for the client.
*/
public class AuthResponseData extends DObject
{
/** The constant used to indicate a successful authentication. */
public static final String SUCCESS = "success";
/**
* Either the {@link #SUCCESS} constant or a reason code indicating
* why the authentication failed.
*/
public String code;
}
@@ -0,0 +1,45 @@
//
// $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.net;
import java.util.List;
import com.threerings.io.SimpleStreamableObject;
import com.threerings.presents.data.InvocationMarshaller;
/**
* A <code>BootstrapData</code> object is communicated back to the client after authentication has
* succeeded and after the server is fully prepared to deal with the client. It contains
* information the client will need to interact with the server.
*/
public class BootstrapData extends SimpleStreamableObject
{
/** The unique id of the client's connection (used to address datagrams). */
public int connectionId;
/** The oid of this client's associated distributed object. */
public int clientOid;
/** A list of handles to invocation services. */
public List<InvocationMarshaller> services;
}
@@ -0,0 +1,63 @@
//
// $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.net;
/**
* A bootstrap notification is delivered to the client once the server has
* fully initialized itself in preparation for dealing with this client.
* The authentication process completes very early and further information
* need be communicated to the client so that it can fully interact with
* the server. This information is communicated via the bootstrap
* notification.
*/
public class BootstrapNotification extends DownstreamMessage
{
/**
* Zero argument constructor used when unserializing an instance.
*/
public BootstrapNotification ()
{
super();
}
/**
* Constructs an bootstrap notification with the supplied data.
*/
public BootstrapNotification (BootstrapData data)
{
_data = data;
}
public BootstrapData getData ()
{
return _data;
}
@Override
public String toString ()
{
return "[type=BOOT, msgid=" + messageId + ", data=" + _data + "]";
}
/** The data associated with this notification. */
protected BootstrapData _data;
}
@@ -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.net;
import com.threerings.io.Streamable;
/**
* Credentials are supplied by the client implementation and sent along to the server during the
* authentication process. To provide support for a variety of authentication methods, the
* credentials class is meant to be subclassed for the particular method (ie. password, auth
* digest, etc.) in use in a given system.
*
* <p> All derived classes should provide a no argument constructor so that they can be
* instantiated prior to reconstruction from a data input stream.
*/
public abstract class Credentials implements Streamable
{
/**
* Returns a string to use in a hash on the datagram contents to authenticate client datagrams.
*/
public String getDatagramSecret ()
{
return "";
}
}
@@ -0,0 +1,42 @@
//
// $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.net;
/**
* This class encapsulates a message in the distributed object protocol that flows from the server
* to the client. Downstream messages include object subscription, event forwarding and session
* management.
*/
public abstract class DownstreamMessage extends Message
{
/**
* The message id of the upstream message with which this downstream message is associated (or
* -1 if it is not associated with any upstream message).
*/
public short messageId = -1;
@Override
public String toString ()
{
return "[msgid=" + messageId + "]";
}
}
@@ -0,0 +1,79 @@
//
// $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.net;
import com.threerings.presents.dobj.DEvent;
/**
* Contains an event forwarded from the server.
*/
public class EventNotification extends DownstreamMessage
{
/**
* Zero argument constructor used when unserializing an instance.
*/
public EventNotification ()
{
super();
}
/**
* Constructs an event notification for the supplied event.
*/
public EventNotification (DEvent event)
{
_event = event;
}
public DEvent getEvent ()
{
return _event;
}
@Override
public void setTransport (Transport transport)
{
// the event handles the transport
_event.setTransport(transport);
}
@Override
public Transport getTransport ()
{
return _event.getTransport();
}
@Override
public void noteActualTransport (Transport transport)
{
_event.noteActualTransport(transport);
}
@Override
public String toString ()
{
return "[type=EVT, evt=" + _event + "]";
}
/** The event which we are forwarding. */
protected DEvent _event;
}
@@ -0,0 +1,64 @@
//
// $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.net;
/**
* Communicates failure to subscribe to an object.
*/
public class FailureResponse extends DownstreamMessage
{
/**
* Zero argument constructor used when unserializing an instance.
*/
public FailureResponse ()
{
super();
}
/**
* Constructs a failure response in response to a request for the specified oid.
*/
public FailureResponse (int oid, String message)
{
_oid = oid;
_message = message;
}
public int getOid ()
{
return _oid;
}
public String getMessage ()
{
return _message;
}
@Override
public String toString ()
{
return "[type=FAIL, msgid=" + messageId + ", oid=" + _oid + ", msg=" + _message + "]";
}
protected int _oid;
protected String _message;
}
@@ -0,0 +1,76 @@
//
// $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.net;
import com.threerings.presents.dobj.DEvent;
/**
* Forwards an event to the server for dispatch.
*/
public class ForwardEventRequest extends UpstreamMessage
{
/**
* Zero argument constructor used when unserializing an instance.
*/
public ForwardEventRequest ()
{
super();
}
/**
* Constructs a forward event request for the supplied event.
*/
public ForwardEventRequest (DEvent event)
{
_event = event;
}
/**
* Returns the event that we wish to have forwarded.
*/
public DEvent getEvent ()
{
return _event;
}
@Override
public void setTransport (Transport transport)
{
// the event handles the transport
_event.setTransport(transport);
}
@Override
public Transport getTransport ()
{
return _event.getTransport();
}
@Override
public String toString ()
{
return "[type=FWD, evt=" + _event + "]";
}
/** The event which we are forwarding. */
protected DEvent _event;
}
@@ -0,0 +1,42 @@
//
// $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.net;
/**
* Requests to end our session with the server.
*/
public class LogoffRequest extends UpstreamMessage
{
/**
* Zero argument constructor used when unserializing an instance.
*/
public LogoffRequest ()
{
super();
}
@Override
public String toString ()
{
return "[type=LOGOFF, msgid=" + messageId + "]";
}
}
@@ -0,0 +1,63 @@
//
// $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.net;
import com.threerings.io.SimpleStreamableObject;
/**
* The superclass of {@link UpstreamMessage} and {@link DownstreamMessage}.
*/
public abstract class Message extends SimpleStreamableObject
{
/** A timestamp indicating when this message was received from the network. */
public transient long received;
/**
* Sets the message transport parameters. For messages received over the network, these
* describe the mode of transport over which the message was received. When sending messages,
* they act as a hint as to the type of transport desired. Calling this method may have no
* effect, depending on whether non-default modes of transport are supported for this message
* type.
*/
public void setTransport (Transport transport)
{
// no-op by default
}
/**
* Returns the message transport parameters.
*/
public Transport getTransport ()
{
return Transport.DEFAULT;
}
/**
* For messages sent over the network, this notes the actual type of transport used to deliver
* the message. This may not be the same as the hinted transport for various reasons (message
* too large to send as datagram, no datagram connection established, etc.)
*/
public void noteActualTransport (Transport transport)
{
// no-op by default
}
}
@@ -0,0 +1,63 @@
//
// $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.net;
import com.threerings.presents.dobj.DObject;
/**
* Contains a distributed object to which the client has subscribed.
*
* @param <T> the type of object delivered by the response.
*/
public class ObjectResponse<T extends DObject>
extends DownstreamMessage
{
/**
* Zero argument constructor used when unserializing an instance.
*/
public ObjectResponse ()
{
super();
}
/**
* Constructs an object response with the supplied distributed object.
*/
public ObjectResponse (T dobj)
{
_dobj = dobj;
}
public T getObject ()
{
return _dobj;
}
@Override
public String toString ()
{
return "[type=ORSP, msgid=" + messageId + ", obj=" + _dobj + "]";
}
/** The object which is associated with this response. */
protected T _dobj;
}
@@ -0,0 +1,125 @@
//
// $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.net;
import java.io.IOException;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* Let's the server know we're still alive.
*/
public class PingRequest extends UpstreamMessage
{
/** The number of milliseconds of idle upstream that are allowed to elapse before the client
* sends a ping message to the server to let it know that we're still alive. */
public static final long PING_INTERVAL = 60 * 1000L;
/**
* Zero argument constructor used when unserializing an instance.
*/
public PingRequest ()
{
super();
}
/**
* Creates a new ping request using the specified transport.
*/
public PingRequest (Transport transport)
{
_transport = transport;
}
/**
* Returns a timestamp that was obtained when this packet was encoded by the low-level
* networking code.
*/
public long getPackStamp ()
{
return _packStamp;
}
/**
* Returns a timestamp that was obtained when this packet was decoded by the low-level
* networking code.
*/
public long getUnpackStamp ()
{
return _unpackStamp;
}
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
// grab a timestamp noting when we were encoded into a raw buffer for delivery over the
// network
_packStamp = System.currentTimeMillis();
out.defaultWriteObject();
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
// grab a timestamp noting when we were decoded from a raw buffer after being received over
// the network
_unpackStamp = System.currentTimeMillis();
in.defaultReadObject();
}
@Override
public void setTransport (Transport transport)
{
_transport = transport;
}
@Override
public Transport getTransport ()
{
return _transport;
}
@Override
public String toString ()
{
return "[type=PING, msgid=" + messageId + ", transport=" + _transport + "]";
}
/** A time stamp obtained when we serialize this object. */
protected transient long _packStamp;
/** A time stamp obtained when we unserialize this object (the intent is to get a timestamp as
* close as possible to when the packet was received on the network). */
protected transient long _unpackStamp;
/** The transport parameters. */
protected transient Transport _transport = Transport.DEFAULT;
}
@@ -0,0 +1,153 @@
//
// $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.net;
import java.io.IOException;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import static com.threerings.presents.Log.log;
/**
* Let's the client know the server heard its ping (and that the server and connection are still
* alive).
*/
public class PongResponse extends DownstreamMessage
{
/**
* Zero argument constructor used when unserializing an instance.
*/
public PongResponse ()
{
super();
}
/**
* Constructs a pong response which will use the supplied ping time to establish the end-to-end
* processing delay introduced by the server.
*/
public PongResponse (long pingStamp, Transport transport)
{
// save this for when we are serialized in preparation for delivery over the network
_pingStamp = pingStamp;
_transport = transport;
}
/**
* Returns the time at which this packet was packed for delivery in the time frame of the
* server that sent the packet.
*/
public long getPackStamp ()
{
return _packStamp;
}
/**
* Returns the number of milliseconds that elapsed between the time that the ping which
* instigated this pong was read from the network and the time that this pong was written to
* the network.
*/
public int getProcessDelay ()
{
return _processDelay;
}
/**
* Returns a timestamp that was obtained when this packet was decoded by the low-level
* networking code.
*/
public long getUnpackStamp ()
{
return _unpackStamp;
}
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
// make a note of the time at which we were packed
_packStamp = System.currentTimeMillis();
// the time spent between unpacking the ping and packing the pong is the processing delay
if (_pingStamp == 0L) {
log.warning("Pong response written that was not constructed with a valid ping stamp",
"rsp", this);
_processDelay = 0;
} else {
_processDelay = (int)(_packStamp - _pingStamp);
}
out.defaultWriteObject();
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
// grab a timestamp noting when we were decoded from a raw buffer after being received over
// the network
_unpackStamp = System.currentTimeMillis();
in.defaultReadObject();
}
@Override
public void setTransport (Transport transport)
{
_transport = transport;
}
@Override
public Transport getTransport ()
{
return _transport;
}
@Override
public String toString ()
{
return "[type=PONG, msgid=" + messageId + ", transport=" + _transport + "]";
}
/** The ping unpack stamp provided at construct time to this pong response; only valid on the
* sending process, not the receiving process. */
protected transient long _pingStamp;
/** The timestamp obtained immediately before this packet was sent out over the network. */
protected long _packStamp;
/** The delay in milliseconds between the time that the ping request was read from the network
* and the time the pong response was written to the network. */
protected int _processDelay;
/** A time stamp obtained when we unserialize this object (the intent is to get a timestamp as
* close as possible to when the packet was received on the network). */
protected transient long _unpackStamp;
/** The transport parameters. */
protected transient Transport _transport = Transport.DEFAULT;
}
@@ -0,0 +1,75 @@
//
// $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.net;
import com.samskivert.util.StringUtil;
/**
* Credentials used by service clients (peers, bureaus, etc.). A service would extend this class
* (so that their service clients can be identified by class name).
*/
public abstract class ServiceCreds extends Credentials
{
/** The id of the service client that is authenticating. */
public String clientId;
/**
* Creates credentials for the specified client.
*/
public ServiceCreds (String clientId, String sharedSecret)
{
this.clientId = clientId;
_authToken = createAuthToken(clientId, sharedSecret);
}
/**
* Used when unserializing an instance from the network.
*/
public ServiceCreds ()
{
}
/**
* Validates that these credentials were created with the supplied shared secret.
*/
public boolean areValid (String sharedSecret)
{
return createAuthToken(clientId, sharedSecret).equals(_authToken);
}
@Override // from Object
public String toString ()
{
return getClass().getSimpleName() + "[id=" + clientId + ", token=" + _authToken + "]";
}
/**
* Creates a unique password for the specified node using the supplied shared secret.
*/
protected static String createAuthToken (String clientId, String sharedSecret)
{
return StringUtil.md5hex(clientId + sharedSecret);
}
/** A token created by a call to {@link #createAuthToken}. */
protected String _authToken;
}
@@ -0,0 +1,65 @@
//
// $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.net;
/**
* Requests to subscribe to a particular distributed object.
*/
public class SubscribeRequest extends UpstreamMessage
{
/**
* Zero argument constructor used when unserializing an instance.
*/
public SubscribeRequest ()
{
super();
}
/**
* Constructs a subscribe request for the distributed object with the
* specified object id.
*/
public SubscribeRequest (int oid)
{
_oid = oid;
}
/**
* Returns the oid of the object to which we desire subscription.
*/
public int getOid ()
{
return _oid;
}
@Override
public String toString ()
{
return "[type=SUB, msgid=" + messageId + ", oid=" + _oid + "]";
}
/**
* The object id of the distributed object to which we are
* subscribing.
*/
protected int _oid;
}
@@ -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.net;
/**
* Notifies the server that the client has received its {@link UpdateThrottleMessage}.
*/
public class ThrottleUpdatedMessage extends UpstreamMessage
{
/** The number of messages allowed per second. */
public final int messagesPerSec;
/**
* Zero argument constructor used when unserializing an instance.
*/
public ThrottleUpdatedMessage ()
{
this.messagesPerSec = 0;
}
public ThrottleUpdatedMessage (int messagesPerSec)
{
this.messagesPerSec = messagesPerSec;
}
}
@@ -0,0 +1,34 @@
//
// $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.net;
/**
* Notifies the server that we would like it to send us datagrams.
*/
public class TransmitDatagramsRequest extends UpstreamMessage
{
@Override
public String toString ()
{
return "[type=TRANSMIT_DATAGRAMS, msgid=" + messageId + "]";
}
}
@@ -0,0 +1,262 @@
//
// $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.net;
import com.samskivert.util.HashIntMap;
/**
* Message transport parameters. These include the type of transport and the channel (used to
* define independent streams for ordered transport), and may eventually include message priority,
* etc.
*/
public class Transport
{
/**
* The available types of transport.
*/
public enum Type
{
/**
* Messages are neither guaranteed to arrive nor, if they do arrive, to arrive in order
* and without duplicates. Functionally identical to UDP.
*/
UNRELIABLE_UNORDERED(false, false) {
@Override
public Type combine (Type other) {
return other; // we defer to all
}
},
/**
* Messages are not guaranteed to arrive, but if they do arrive, then they will arrive in
* order and without duplicates. In other words, out-of-order packets will be dropped.
*/
UNRELIABLE_ORDERED(false, true) {
@Override
public Type combine (Type other) {
return other.isReliable() ? RELIABLE_ORDERED : this;
}
},
/**
* Messages are guaranteed to arrive eventually, but they are not guaranteed to arrive in
* order.
*/
RELIABLE_UNORDERED(true, false) {
@Override
public Type combine (Type other) {
return other.isOrdered() ? RELIABLE_ORDERED : this;
}
},
/**
* Messages are guaranteed to arrive, and will arrive in the order in which they are sent.
* Functionally identical to TCP.
*/
RELIABLE_ORDERED(true, true) {
@Override
public Type combine (Type other) {
return this; // we override all
}
};
/**
* Checks whether this transport type guarantees that messages will be delivered.
*/
public boolean isReliable ()
{
return _reliable;
}
/**
* Checks whether this transport type guarantees that messages will be received in the
* order in which they were sent, if they are received at all.
*/
public boolean isOrdered ()
{
return _ordered;
}
/**
* Returns a transport type that combines the requirements of this type with those of the
* specified other type.
*/
public abstract Type combine (Type other);
Type (boolean reliable, boolean ordered)
{
_reliable = reliable;
_ordered = ordered;
}
protected boolean _reliable, _ordered;
}
/** The unreliable/unordered mode of transport. */
public static final Transport UNRELIABLE_UNORDERED = getInstance(Type.UNRELIABLE_UNORDERED);
/** The unreliable/ordered mode on the default channel. */
public static final Transport UNRELIABLE_ORDERED = getInstance(Type.UNRELIABLE_ORDERED, 0);
/** The reliable/unordered mode. */
public static final Transport RELIABLE_UNORDERED = getInstance(Type.RELIABLE_UNORDERED);
/** The reliable/ordered mode on the default channel. */
public static final Transport RELIABLE_ORDERED = getInstance(Type.RELIABLE_ORDERED, 0);
/** The default mode of transport. */
public static final Transport DEFAULT = RELIABLE_ORDERED;
/**
* Returns the shared instance with the specified parameters.
*/
public static Transport getInstance (Type type)
{
return getInstance(type, 0);
}
/**
* Returns the shared instance with the specified parameters.
*/
public static Transport getInstance (Type type, int channel)
{
// were there more parameters in transport objects, it would be better to have a single map
// of instances and use Transport objects as keys (as in examples of the flyweight
// pattern). however, doing it this way avoids the need to create a new object on lookup
if (_unordered == null) {
int length = Type.values().length;
_unordered = new Transport[length];
@SuppressWarnings("unchecked") HashIntMap<Transport>[] ordered = new HashIntMap[length];
_ordered = ordered;
}
// for unordered transport, we map on the type alone
int idx = type.ordinal();
if (!type.isOrdered()) {
Transport instance = _unordered[idx];
if (instance == null) {
_unordered[idx] = instance = new Transport(type);
}
return instance;
}
// for ordered transport, we map on the type and channel
HashIntMap<Transport> instances = _ordered[idx];
if (instances == null) {
_ordered[idx] = instances = new HashIntMap<Transport>();
}
Transport instance = instances.get(channel);
if (instance == null) {
instances.put(channel, instance = new Transport(type, channel));
}
return instance;
}
/**
* Returns the type of transport.
*/
public Type getType ()
{
return _type;
}
/**
* Returns the transport channel.
*/
public int getChannel ()
{
return _channel;
}
/**
* Checks whether this transport guarantees that messages will be delivered.
*/
public boolean isReliable ()
{
return _type.isReliable();
}
/**
* Checks whether this transport guarantees that messages will be received in the order in
* which they were sent, if they are received at all.
*/
public boolean isOrdered ()
{
return _type.isOrdered();
}
/**
* Returns a transport that satisfies the requirements of this and the specified other
* transport.
*/
public Transport combine (Transport other)
{
// if the channels are different, we fall back to the default channel
return getInstance(
_type.combine(other._type),
(_channel == other._channel) ? _channel : 0);
}
@Override
public int hashCode ()
{
return 31*_type.hashCode() + _channel;
}
@Override
public boolean equals (Object other)
{
Transport otrans;
return other instanceof Transport && (otrans = (Transport)other)._type == _type &&
otrans._channel == _channel;
}
@Override
public String toString ()
{
return "[type=" + _type + ", channel=" + _channel + "]";
}
protected Transport (Type type)
{
this(type, 0);
}
protected Transport (Type type, int channel)
{
_type = type;
_channel = channel;
}
/** The type of transport. */
protected Type _type;
/** The transport channel. */
protected int _channel;
/** Unordered instances mapped by type (would use {@link java.util.EnumMap}, but it doesn't
* work with Retroweaver). */
protected static Transport[] _unordered;
/** Ordered instances mapped by type and channel. */
protected static HashIntMap<Transport>[] _ordered;
}
@@ -0,0 +1,65 @@
//
// $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.net;
/**
* Requests to end a subscription to a particular distributed object.
*/
public class UnsubscribeRequest extends UpstreamMessage
{
/**
* Zero argument constructor used when unserializing an instance.
*/
public UnsubscribeRequest ()
{
super();
}
/**
* Constructs a unsubscribe request for the distributed object
* with the specified object id.
*/
public UnsubscribeRequest (int oid)
{
_oid = oid;
}
/**
* Returns the oid of the object from which we are unsubscribing.
*/
public int getOid ()
{
return _oid;
}
@Override
public String toString ()
{
return "[type=UNSUB, msgid=" + messageId + ", oid=" + _oid + "]";
}
/**
* The object id of the distributed object from which we are
* unsubscribing.
*/
protected int _oid;
}
@@ -0,0 +1,59 @@
//
// $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.net;
/**
* Used to communicate to the client that we received their unsubscribe
* request and that it is now OK to remove an object mapping from their
* local object table.
*/
public class UnsubscribeResponse extends DownstreamMessage
{
/**
* Zero argument constructor used when unserializing an instance.
*/
public UnsubscribeResponse ()
{
super();
}
/**
* Constructs an unsubscribe response with the supplied oid.
*/
public UnsubscribeResponse (int oid)
{
_oid = oid;
}
public int getOid ()
{
return _oid;
}
@Override
public String toString ()
{
return "[type=UNACK, msgid=" + messageId + ", oid=" + _oid + "]";
}
protected int _oid;
}
@@ -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.net;
/**
* Notifies the client that its message throttle has been updated.
*/
public class UpdateThrottleMessage extends DownstreamMessage
{
/** The number of messages allowed per second. */
public final int messagesPerSec;
/**
* Zero argument constructor used when unserializing an instance.
*/
public UpdateThrottleMessage ()
{
this.messagesPerSec = 0;
}
public UpdateThrottleMessage (int messagesPerSec)
{
this.messagesPerSec = messagesPerSec;
}
}
@@ -0,0 +1,70 @@
//
// $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.net;
/**
* This class encapsulates a message in the distributed object protocol that flows from the client
* to the server. Upstream messages include object subscription, event forwarding and session
* management.
*/
public abstract class UpstreamMessage extends Message
{
/**
* This is a unique (within the context of a reasonable period of time) identifier assigned to
* each upstream message. The message ids are used to correlate a downstream response message
* to the appropriate upstream request message.
*/
public short messageId;
/**
* Each upstream message derived class must provide a zero argument constructor so that it can
* be unserialized when read from the network.
*/
public UpstreamMessage ()
{
// automatically generate a valid message id; on the client, this
// will be used, on the server it will be overwritten by the
// unserialized value
this.messageId = nextMessageId();
}
@Override
public String toString ()
{
return "[msgid=" + messageId + "]";
}
/**
* Returns the next message id suitable for use by an upstream message.
*/
protected static synchronized short nextMessageId ()
{
_nextMessageId = (short)((_nextMessageId + 1) % Short.MAX_VALUE);
return _nextMessageId;
}
/**
* This is used to generate monotonically increasing message ids on the client as new messages
* are generated.
*/
protected static short _nextMessageId;
}
@@ -0,0 +1,82 @@
//
// $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.net;
import com.threerings.util.Name;
/**
* Credentials that use a username and (hashed) password.
*/
public class UsernamePasswordCreds extends Credentials
{
/**
* Zero argument constructor used when unserializing an instance.
*/
public UsernamePasswordCreds ()
{
}
/**
* Construct credentials with the supplied username and password.
*/
public UsernamePasswordCreds (Name username, String password)
{
_username = username;
_password = password;
}
public Name getUsername ()
{
return _username;
}
public String getPassword ()
{
return _password;
}
@Override
public String getDatagramSecret ()
{
return _password;
}
@Override
public String toString ()
{
StringBuilder buf = new StringBuilder("[");
toString(buf);
return buf.append("]").toString();
}
/**
* An easily extensible method via which derived classes can add to {@link #toString}'s output.
*/
protected void toString (StringBuilder buf)
{
buf.append("username=").append(_username);
buf.append(", password=").append(_password);
}
protected Name _username;
protected String _password;
}