Class ServiceDispatcher
- java.lang.Object
-
- org.simpleframework.http.socket.service.ServiceDispatcher
-
class ServiceDispatcher extends java.lang.Object
TheServiceDispatcher
object is used to perform the opening handshake for a WebSocket session. Once the session has been established it is connected to aService
where 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 SessionBuilder
builder
This is used to build the sessions from the handshake request.private SessionDispatcher
dispatcher
This is the session dispatcher used to dispatch the session.private Reactor
reactor
This is used to notify of read events on the TCP channel.private Scheduler
scheduler
This is used asynchronously read frames from the TCP channel.
-
Constructor Summary
Constructors Constructor Description ServiceDispatcher(Router router, int threads)
Constructor for theServiceDispatcher
object.ServiceDispatcher(Router router, int threads, long ping)
Constructor for theServiceDispatcher
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispatch(Request request, Response response)
This method is used to create a dispatch aSession
to 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 theServiceDispatcher
object. The dispatcher created will dispatch WebSocket sessions to a service using the providedRouter
instance.- 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 theServiceDispatcher
object. The dispatcher created will dispatch WebSocket sessions to a service using the providedRouter
instance.- 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 aSession
to 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
-
-