-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebSocketDispatcher.java
36 lines (32 loc) · 1.35 KB
/
WebSocketDispatcher.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package server;
import sirius.kernel.di.std.Register;
import sirius.web.http.WebContext;
import sirius.web.http.WebsocketDispatcher;
import sirius.web.http.WebsocketSession;
/**
* Simple {@link WebSocketDispatcher} that propagates calls to '/websocket' into a {@link ChatSession}.
* <p>
* Note that the description below is provided to understand the framework and its inner workings. You do not need to
* read and understand all that to master the challenges... :)
* <p>
* As this class wears a {@link Register} annotation and implements {@link WebSocketDispatcher} the
* {@link sirius.kernel.di.std.AutoRegisterAction} of <tt>sirius-kernel</tt> will instantiate this class and put
* it into the {@link sirius.kernel.di.PartRegistry} of the {@link sirius.kernel.di.Injector}.
* <p>
* If now the <tt>web server</tt> (the {@link sirius.web.http.WebsocketHandler} to be exact) detects an incoming
* web socket, if checks which dispatcher is responsible via {@link #getWebsocketUri()} and invokes the respective
* {@link #createSession(WebContext)}.
*
* @see ChatSession
*/
@Register
public class WebSocketDispatcher implements WebsocketDispatcher {
@Override
public String getWebsocketUri() {
return "/websocket";
}
@Override
public WebsocketSession createSession(WebContext webContext) {
return new ChatSession(webContext);
}
}