com.threerings.nexus.net
Class Connection

java.lang.Object
  extended by com.threerings.nexus.net.Connection
All Implemented Interfaces:
EventSink, Downstream.Handler

public abstract class Connection
extends Object
implements Downstream.Handler, EventSink

Manages a connection to a particular server.


Field Summary
 react.Signal<Throwable> onClose
          A signal emitted when this connection is closed.
 
Method Summary
abstract  void close()
          Closes this connection in an orderly fashion.
 String getHost()
          Returns the name of the host that is associated with this event sink.
 void onDispatchEvent(Downstream.DispatchEvent msg)
          Dispatches an event originating on the server.
 void onObjectCleared(Downstream.ObjectCleared msg)
          Dispatches an object cleared notification.
 void onServiceFailure(Downstream.ServiceFailure msg)
          Dispatches a failed service notification from the server.
 void onServiceResponse(Downstream.ServiceResponse msg)
          Dispatches a service response from the server.
 void onSubscribe(Downstream.Subscribe msg)
          Dispatches a successful subscribe response.
 void onSubscribeFailure(Downstream.SubscribeFailure msg)
          Dispatches a failed subscribe response.
 void postCall(NexusObject source, short attrIndex, short methodId, Object[] args)
          Posts a service request originating from the specified object.
 void postEvent(NexusObject source, NexusEvent event)
          Posts an event originating from the specified object, to be dispatched to local and distributed listeners.
<T extends NexusObject>
void
subscribe(Address<T> addr, Callback<T> cb)
          Requests to subscribe to the specified Nexus object.
 void unsubscribe(NexusObject object)
          Requests to unsubscribe from the specified Nexus object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

onClose

public final react.Signal<Throwable> onClose
A signal emitted when this connection is closed. The payload will be non-null if the connection was closed in error, null if it was closed in an orderly manner.

Method Detail

subscribe

public <T extends NexusObject> void subscribe(Address<T> addr,
                                              Callback<T> cb)
Requests to subscribe to the specified Nexus object. Success (i.e. the object) or failure will be communicated via the supplied callback.


unsubscribe

public void unsubscribe(NexusObject object)
Requests to unsubscribe from the specified Nexus object.


close

public abstract void close()
Closes this connection in an orderly fashion. Any messages currently queued up should be delivered prior to closure.


getHost

public String getHost()
Description copied from interface: EventSink
Returns the name of the host that is associated with this event sink. This is used by Nexus objects to construct their address.

Specified by:
getHost in interface EventSink

postEvent

public void postEvent(NexusObject source,
                      NexusEvent event)
Description copied from interface: EventSink
Posts an event originating from the specified object, to be dispatched to local and distributed listeners.

Specified by:
postEvent in interface EventSink

postCall

public void postCall(NexusObject source,
                     short attrIndex,
                     short methodId,
                     Object[] args)
Description copied from interface: EventSink
Posts a service request originating from the specified object. It will be distributed upstream.

Specified by:
postCall in interface EventSink

onSubscribe

public void onSubscribe(Downstream.Subscribe msg)
Description copied from interface: Downstream.Handler
Dispatches a successful subscribe response.

Specified by:
onSubscribe in interface Downstream.Handler

onSubscribeFailure

public void onSubscribeFailure(Downstream.SubscribeFailure msg)
Description copied from interface: Downstream.Handler
Dispatches a failed subscribe response.

Specified by:
onSubscribeFailure in interface Downstream.Handler

onDispatchEvent

public void onDispatchEvent(Downstream.DispatchEvent msg)
Description copied from interface: Downstream.Handler
Dispatches an event originating on the server.

Specified by:
onDispatchEvent in interface Downstream.Handler

onServiceResponse

public void onServiceResponse(Downstream.ServiceResponse msg)
Description copied from interface: Downstream.Handler
Dispatches a service response from the server.

Specified by:
onServiceResponse in interface Downstream.Handler

onServiceFailure

public void onServiceFailure(Downstream.ServiceFailure msg)
Description copied from interface: Downstream.Handler
Dispatches a failed service notification from the server.

Specified by:
onServiceFailure in interface Downstream.Handler

onObjectCleared

public void onObjectCleared(Downstream.ObjectCleared msg)
Description copied from interface: Downstream.Handler
Dispatches an object cleared notification.

Specified by:
onObjectCleared in interface Downstream.Handler


Copyright © 2013. All Rights Reserved.