Further progress. Heeya!
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: AuthRequest.java,v 1.1 2001/05/22 06:07:59 mdb Exp $
|
||||
// $Id: AuthRequest.java,v 1.2 2001/05/22 21:51:29 mdb Exp $
|
||||
|
||||
package com.samskivert.cocktail.cher.net;
|
||||
|
||||
@@ -9,23 +9,23 @@ import java.io.DataOutputStream;
|
||||
|
||||
import com.samskivert.cocktail.cher.io.TypedObjectFactory;
|
||||
|
||||
public class AuthenticationRequest extends UpstreamMessage
|
||||
public class AuthRequest extends UpstreamMessage
|
||||
{
|
||||
/** The code for an object subscription request. */
|
||||
/** The code for an auth request. */
|
||||
public static final short TYPE = TYPE_BASE + 0;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
public AuthenticationRequest ()
|
||||
public AuthRequest ()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a authentication request with the supplied credentials.
|
||||
* Constructs a auth request with the supplied credentials.
|
||||
*/
|
||||
public AuthenticationRequest (Credentials creds)
|
||||
public AuthRequest (Credentials creds)
|
||||
{
|
||||
_creds = creds;
|
||||
}
|
||||
@@ -50,8 +50,7 @@ public class AuthenticationRequest extends UpstreamMessage
|
||||
}
|
||||
|
||||
/**
|
||||
* The object id of the distributed object to which we are
|
||||
* subscribing.
|
||||
* The credentials associated with this auth request.
|
||||
*/
|
||||
protected Credentials _creds;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// $Id: AuthResponse.java,v 1.1 2001/05/22 21:51:29 mdb Exp $
|
||||
|
||||
package com.samskivert.cocktail.cher.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.samskivert.cocktail.cher.dobj.DObject;
|
||||
import com.samskivert.cocktail.cher.io.TypedObjectFactory;
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
/** The code for an auth response. */
|
||||
public static final short TYPE = TYPE_BASE + 0;
|
||||
|
||||
/** The response code key in the data object. */
|
||||
public static final String CODE = "code";
|
||||
|
||||
/** The failure reason key in the data object. */
|
||||
public static final String REASON = "reason";
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
public AuthResponse ()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a auth response with the supplied credentials.
|
||||
*/
|
||||
public AuthResponse (DObject data)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public DObject getData ()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
_data.writeTo(out);
|
||||
}
|
||||
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
{
|
||||
super.readFrom(in);
|
||||
_data = (DObject)TypedObjectFactory.readFrom(in);
|
||||
}
|
||||
|
||||
protected DObject _data;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: DownstreamMessage.java,v 1.1 2001/05/22 06:07:59 mdb Exp $
|
||||
// $Id: DownstreamMessage.java,v 1.2 2001/05/22 21:51:29 mdb Exp $
|
||||
|
||||
package com.samskivert.cocktail.cher.net;
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.samskivert.cocktail.cher.io.TypedObjectFactory;
|
||||
* client. Downstream messages include object subscription, event
|
||||
* forwarding and session management.
|
||||
*/
|
||||
public class DownstreamMessage
|
||||
public abstract class DownstreamMessage extends TypedObject
|
||||
{
|
||||
/**
|
||||
* All downstream message derived classes should base their typed
|
||||
@@ -43,30 +43,15 @@ public class DownstreamMessage
|
||||
|
||||
// register our downstream message classes
|
||||
static {
|
||||
TypedObjectFactory.registerClass(AuthenticationRequest.TYPE,
|
||||
AuthenticationRequest.class);
|
||||
TypedObjectFactory.registerClass(SubscribeRequest.TYPE,
|
||||
SubscribeRequest.class);
|
||||
TypedObjectFactory.registerClass(FetchRequest.TYPE,
|
||||
FetchRequest.class);
|
||||
TypedObjectFactory.registerClass(UnsubscribeNotification.TYPE,
|
||||
UnsubscribeNotification.class);
|
||||
TypedObjectFactory.registerClass(ForwardEventNotification.TYPE,
|
||||
ForwardEventNotification.class);
|
||||
TypedObjectFactory.registerClass(PingNotification.TYPE,
|
||||
PingNotification.class);
|
||||
TypedObjectFactory.registerClass(LogoffNotification.TYPE,
|
||||
LogoffNotification.class);
|
||||
TypedObjectFactory.registerClass(AuthResponse.TYPE,
|
||||
AuthResponse.class);
|
||||
TypedObjectFactory.registerClass(EventNotification.TYPE,
|
||||
EventNotification.class);
|
||||
TypedObjectFactory.registerClass(ObjectResponse.TYPE,
|
||||
ObjectResponse.class);
|
||||
TypedObjectFactory.registerClass(FailureResponse.TYPE,
|
||||
FailureResponse.class);
|
||||
TypedObjectFactory.registerClass(PongNotification.TYPE,
|
||||
PongNotification.class);
|
||||
}
|
||||
|
||||
/** The code for an event notification. */
|
||||
public static final byte EVENT = 0x00;
|
||||
/** The code for a fetch/subscribe object response. */
|
||||
public static final byte OBJECT = 0x01;
|
||||
/** The code for a request failure. */
|
||||
public static final byte FAILURE = 0x02;
|
||||
/** The code for a pong response. */
|
||||
public static final byte PONG = 0x03;
|
||||
/** The code for an end of transmission notification. */
|
||||
public static final byte EOT = 0x04;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
//
|
||||
// $Id: EventNotification.java,v 1.1 2001/05/22 06:07:59 mdb Exp $
|
||||
// $Id: EventNotification.java,v 1.2 2001/05/22 21:51:29 mdb Exp $
|
||||
|
||||
package com.samskivert.cocktail.cher.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.samskivert.cocktail.cher.dobj.Event;
|
||||
import com.samskivert.cocktail.cher.dobj.EventFactory;
|
||||
|
||||
public class EventNotification extends DownstreamMessage
|
||||
{
|
||||
/** The code for an event notification. */
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// $Id: FailureResponse.java,v 1.1 2001/05/22 21:51:29 mdb Exp $
|
||||
|
||||
package com.samskivert.cocktail.cher.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
public class FailureResponse extends DownstreamMessage
|
||||
{
|
||||
/** The code for a logoff notification. */
|
||||
public static final short TYPE = TYPE_BASE + 3;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
public FailureResponse ()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a failure response that is associated with the specified
|
||||
* upstream message id.
|
||||
*/
|
||||
public FailureResponse (short messageId)
|
||||
{
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
out.writeShort(messageId);
|
||||
}
|
||||
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
{
|
||||
super.readFrom(in);
|
||||
messageId = in.readShort();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// $Id: ObjectResponse.java,v 1.1 2001/05/22 21:51:29 mdb Exp $
|
||||
|
||||
package com.samskivert.cocktail.cher.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.samskivert.cocktail.cher.dobj.DObject;
|
||||
import com.samskivert.cocktail.cher.io.TypedObjectFactory;
|
||||
|
||||
public class ObjectResponse extends DownstreamMessage
|
||||
{
|
||||
/** The code for an event notification. */
|
||||
public static final short TYPE = TYPE_BASE + 2;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
public ObjectResponse ()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an object response with supplied distributed object that
|
||||
* is associated with the specified upstream message id.
|
||||
*/
|
||||
public ObjectResponse (short messageId, DObject dobj)
|
||||
{
|
||||
this.messageId = messageId;
|
||||
_dobj = dobj;
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
out.writeShort(messageId);
|
||||
_dobj.writeTo(out);
|
||||
}
|
||||
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
{
|
||||
super.readFrom(in);
|
||||
messageId = in.readShort();
|
||||
_dobj = (DObject)TypedObjectFactory.readFrom(in);
|
||||
}
|
||||
|
||||
/** The object which is associated with this response. */
|
||||
protected DObject _dobj;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// $Id: PongResponse.java,v 1.1 2001/05/22 21:51:29 mdb Exp $
|
||||
|
||||
package com.samskivert.cocktail.cher.net;
|
||||
|
||||
public class PongNotification extends DownstreamMessage
|
||||
{
|
||||
/** The code for a pong notification. */
|
||||
public static final short TYPE = TYPE_BASE + 4;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
public PongNotification ()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: UpstreamMessage.java,v 1.1 2001/05/22 06:08:00 mdb Exp $
|
||||
// $Id: UpstreamMessage.java,v 1.2 2001/05/22 21:51:29 mdb Exp $
|
||||
|
||||
package com.samskivert.cocktail.cher.net;
|
||||
|
||||
@@ -87,8 +87,8 @@ public abstract class UpstreamMessage extends TypedObject
|
||||
|
||||
// register our upstream message classes
|
||||
static {
|
||||
TypedObjectFactory.registerClass(AuthenticationRequest.TYPE,
|
||||
AuthenticationRequest.class);
|
||||
TypedObjectFactory.registerClass(AuthRequest.TYPE,
|
||||
AuthRequest.class);
|
||||
TypedObjectFactory.registerClass(SubscribeRequest.TYPE,
|
||||
SubscribeRequest.class);
|
||||
TypedObjectFactory.registerClass(FetchRequest.TYPE,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: UsernamePasswordCreds.java,v 1.1 2001/05/22 06:08:00 mdb Exp $
|
||||
// $Id: UsernamePasswordCreds.java,v 1.2 2001/05/22 21:51:29 mdb Exp $
|
||||
|
||||
package com.samskivert.cocktail.cher.net;
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class UsernamePasswordCreds
|
||||
public class UsernamePasswordCreds extends Credentials
|
||||
{
|
||||
public static final short TYPE = TYPE_BASE + 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user