Moved the typed object registry into the same package with the rest of
the typed object stuff; made events typed so they can be transported; further wiring up of event dispatch over the network. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@34 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: EventNotification.java,v 1.6 2001/06/09 23:39:04 mdb Exp $
|
||||
// $Id: EventNotification.java,v 1.7 2001/06/11 17:44:04 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.net;
|
||||
|
||||
@@ -7,7 +7,8 @@ import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.cocktail.cher.dobj.DEvent;
|
||||
import com.threerings.cocktail.cher.dobj.TypedEvent;
|
||||
import com.threerings.cocktail.cher.io.TypedObjectFactory;
|
||||
|
||||
public class EventNotification extends DownstreamMessage
|
||||
{
|
||||
@@ -25,7 +26,7 @@ public class EventNotification extends DownstreamMessage
|
||||
/**
|
||||
* Constructs an event notification for the supplied event.
|
||||
*/
|
||||
public EventNotification (DEvent event)
|
||||
public EventNotification (TypedEvent event)
|
||||
{
|
||||
_event = event;
|
||||
}
|
||||
@@ -35,7 +36,7 @@ public class EventNotification extends DownstreamMessage
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public DEvent getEvent ()
|
||||
public TypedEvent getEvent ()
|
||||
{
|
||||
return _event;
|
||||
}
|
||||
@@ -44,16 +45,18 @@ public class EventNotification extends DownstreamMessage
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
// _event.writeTo(out);
|
||||
// write the event out to the stream
|
||||
TypedObjectFactory.writeTo(out, _event);
|
||||
}
|
||||
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
{
|
||||
super.readFrom(in);
|
||||
// _event = EventFactory.readFrom(in);
|
||||
// read the event in from the stream
|
||||
_event = (TypedEvent)TypedObjectFactory.readFrom(in);
|
||||
}
|
||||
|
||||
/** The event which we are forwarding. */
|
||||
protected DEvent _event;
|
||||
protected TypedEvent _event;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ForwardEventRequest.java,v 1.6 2001/06/05 22:44:31 mdb Exp $
|
||||
// $Id: ForwardEventRequest.java,v 1.7 2001/06/11 17:44:04 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.net;
|
||||
|
||||
@@ -7,7 +7,8 @@ import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.cocktail.cher.dobj.DEvent;
|
||||
import com.threerings.cocktail.cher.dobj.TypedEvent;
|
||||
import com.threerings.cocktail.cher.io.TypedObjectFactory;
|
||||
|
||||
public class ForwardEventRequest extends UpstreamMessage
|
||||
{
|
||||
@@ -25,7 +26,7 @@ public class ForwardEventRequest extends UpstreamMessage
|
||||
/**
|
||||
* Constructs a forward event request for the supplied event.
|
||||
*/
|
||||
public ForwardEventRequest (DEvent event)
|
||||
public ForwardEventRequest (TypedEvent event)
|
||||
{
|
||||
_event = event;
|
||||
}
|
||||
@@ -38,7 +39,7 @@ public class ForwardEventRequest extends UpstreamMessage
|
||||
/**
|
||||
* Returns the event that we wish to have forwarded.
|
||||
*/
|
||||
public DEvent getEvent ()
|
||||
public TypedEvent getEvent ()
|
||||
{
|
||||
return _event;
|
||||
}
|
||||
@@ -47,16 +48,18 @@ public class ForwardEventRequest extends UpstreamMessage
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
// _event.writeTo(out);
|
||||
// write the event out to the stream
|
||||
TypedObjectFactory.writeTo(out, _event);
|
||||
}
|
||||
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
{
|
||||
super.readFrom(in);
|
||||
// _event = EventFactory.readFrom(in);
|
||||
// read the event in from the stream
|
||||
_event = (TypedEvent)TypedObjectFactory.readFrom(in);
|
||||
}
|
||||
|
||||
/** The event which we are forwarding. */
|
||||
protected DEvent _event;
|
||||
protected TypedEvent _event;
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
//
|
||||
// $Id: Registry.java,v 1.5 2001/06/09 23:39:04 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.net;
|
||||
|
||||
import com.threerings.cocktail.cher.dobj.DObject;
|
||||
import com.threerings.cocktail.cher.io.TypedObject;
|
||||
import com.threerings.cocktail.cher.io.TypedObjectFactory;
|
||||
|
||||
/**
|
||||
* The registry provides a single place where all typed objects that are
|
||||
* exchanged between the client and the server can be registered with the
|
||||
* typed object factory.
|
||||
*/
|
||||
public class Registry
|
||||
{
|
||||
/**
|
||||
* Must be called once by the client and the server to ensure that all
|
||||
* typed objects are registered with the typed object system.
|
||||
*/
|
||||
public static void registerTypedObjects ()
|
||||
{
|
||||
// register our upstream message classes
|
||||
TypedObjectFactory.registerClass(AuthRequest.TYPE,
|
||||
AuthRequest.class);
|
||||
TypedObjectFactory.registerClass(SubscribeRequest.TYPE,
|
||||
SubscribeRequest.class);
|
||||
TypedObjectFactory.registerClass(UnsubscribeRequest.TYPE,
|
||||
UnsubscribeRequest.class);
|
||||
TypedObjectFactory.registerClass(ForwardEventRequest.TYPE,
|
||||
ForwardEventRequest.class);
|
||||
TypedObjectFactory.registerClass(PingRequest.TYPE,
|
||||
PingRequest.class);
|
||||
TypedObjectFactory.registerClass(LogoffRequest.TYPE,
|
||||
LogoffRequest.class);
|
||||
|
||||
// register our downstream message classes
|
||||
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(PongResponse.TYPE,
|
||||
PongResponse.class);
|
||||
|
||||
// register our credential classes
|
||||
TypedObjectFactory.registerClass(UsernamePasswordCreds.TYPE,
|
||||
UsernamePasswordCreds.class);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user