Class ServiceDispatcher
java.lang.Object
org.simpleframework.http.socket.service.ServiceDispatcher
The
ServiceDispatcher
object is used to perform the
opening handshake for a WebSocket session. Once the session has been
established it is connected to a Service
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
FieldsModifier and TypeFieldDescriptionprivate final SessionBuilder
This is used to build the sessions from the handshake request.private final SessionDispatcher
This is the session dispatcher used to dispatch the session.private final Reactor
This is used to notify of read events on the TCP channel.private final Scheduler
This is used asynchronously read frames from the TCP channel. -
Constructor Summary
ConstructorsConstructorDescriptionServiceDispatcher
(Router router, int threads) Constructor for theServiceDispatcher
object.ServiceDispatcher
(Router router, int threads, long ping) Constructor for theServiceDispatcher
object. -
Method Summary
-
Field Details
-
dispatcher
This is the session dispatcher used to dispatch the session. -
builder
This is used to build the sessions from the handshake request. -
scheduler
This is used asynchronously read frames from the TCP channel. -
reactor
This is used to notify of read events on the TCP channel.
-
-
Constructor Details
-
ServiceDispatcher
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:
IOException
-
ServiceDispatcher
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:
IOException
-
-
Method Details
-
dispatch
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
-