|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import {Controller, view, Session, Inject, Injectable, Locale, Validator} from '@extollo/lib'
|
|
|
|
|
import {Controller, view, Session, Inject, Injectable, Locale, Validator, WebSocketBus, JSONMessageEvent, Logging, Bus, WebSocketCloseEvent} from '@extollo/lib'
|
|
|
|
|
import {UserLogin} from "../../../types/UserLogin";
|
|
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
@ -9,6 +9,9 @@ export class Home extends Controller {
|
|
|
|
|
@Inject()
|
|
|
|
|
protected readonly locale!: Locale;
|
|
|
|
|
|
|
|
|
|
@Inject()
|
|
|
|
|
protected readonly logging!: Logging
|
|
|
|
|
|
|
|
|
|
public welcome() {
|
|
|
|
|
this.session.set('app_visits', this.session.get('app_visits', 0) + 1)
|
|
|
|
|
|
|
|
|
@ -20,6 +23,22 @@ export class Home extends Controller {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async socket(ws: WebSocketBus): Promise<void> {
|
|
|
|
|
ws.subscribe(JSONMessageEvent, event => {
|
|
|
|
|
this.logging.info('Got JSON message event:')
|
|
|
|
|
this.logging.debug(event.value)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const interval = setInterval(() => {
|
|
|
|
|
ws.push(new JSONMessageEvent({ hello: 'world!' }))
|
|
|
|
|
}, 5000)
|
|
|
|
|
|
|
|
|
|
await this.request.make<Bus>(Bus)
|
|
|
|
|
.subscribe(WebSocketCloseEvent, () => {
|
|
|
|
|
clearInterval(interval)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public test() {
|
|
|
|
|
return new Validator<UserLogin>()
|
|
|
|
|
}
|
|
|
|
|