Class ServiceDispatcher
- java.lang.Object
-
- org.simpleframework.http.socket.service.ServiceDispatcher
-
class ServiceDispatcher extends java.lang.ObjectTheServiceDispatcherobject is used to perform the opening handshake for a WebSocket session. Once the session has been established it is connected to aServicewhere frames can be sent and received. If for any reason the handshake fails this will terminated the connection with a HTTP 400 response.
-
-
Field Summary
Fields Modifier and Type Field Description private SessionBuilderbuilderThis is used to build the sessions from the handshake request.private SessionDispatcherdispatcherThis is the session dispatcher used to dispatch the session.private ReactorreactorThis is used to notify of read events on the TCP channel.private SchedulerschedulerThis is used asynchronously read frames from the TCP channel.
-
Constructor Summary
Constructors Constructor Description ServiceDispatcher(Router router, int threads)Constructor for theServiceDispatcherobject.ServiceDispatcher(Router router, int threads, long ping)Constructor for theServiceDispatcherobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispatch(Request request, Response response)This method is used to create a dispatch aSessionto a specific service selected by a router.
-
-
-
Field Detail
-
dispatcher
private final SessionDispatcher dispatcher
This is the session dispatcher used to dispatch the session.
-
builder
private final SessionBuilder builder
This is used to build the sessions from the handshake request.
-
scheduler
private final Scheduler scheduler
This is used asynchronously read frames from the TCP channel.
-
reactor
private final Reactor reactor
This is used to notify of read events on the TCP channel.
-
-
Constructor Detail
-
ServiceDispatcher
public ServiceDispatcher(Router router, int threads) throws java.io.IOException
Constructor for theServiceDispatcherobject. The dispatcher created will dispatch WebSocket sessions to a service using the providedRouterinstance.- Parameters:
router- this is the router used to select a servicethreads- this is the number of threads to use- Throws:
java.io.IOException
-
ServiceDispatcher
public ServiceDispatcher(Router router, int threads, long ping) throws java.io.IOException
Constructor for theServiceDispatcherobject. The dispatcher created will dispatch WebSocket sessions to a service using the providedRouterinstance.- Parameters:
router- this is the router used to select a servicethreads- this is the number of threads to useping- this is the frequency used to send ping frames- Throws:
java.io.IOException
-
-
Method Detail
-
dispatch
public void dispatch(Request request, Response response)
This method is used to create a dispatch aSessionto a specific service selected by a router. If the session initiating handshake fails for any reason this will close the underlying TCP connection and send a HTTP 400 response back to the client.- Parameters:
request- this is the session initiating requestresponse- this is the session initiating response
-
-