This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
seepur/start/wsKernel.js

40 lines
996 B
JavaScript
Raw Normal View History

2020-04-12 14:25:42 +00:00
'use strict'
const Ws = use('Ws');
/*
|--------------------------------------------------------------------------
| Global middleware
|--------------------------------------------------------------------------
|
| Global middleware are executed on each Websocket channel subscription.
|
*/
const globalMiddleware =
['Adonis/Middleware/Session', 'Adonis/Middleware/AuthInit'];
/*
|--------------------------------------------------------------------------
| Named middleware
|--------------------------------------------------------------------------
|
| Named middleware are defined as key/value pairs. Later you can use the
| keys to run selected middleware on a given channel.
|
| // define
| {
| auth: 'Adonis/Middleware/Auth'
| }
|
| // use
| Ws.channel('chat', 'ChatController').middleware(['auth'])
*/
const namedMiddleware = {
auth: 'Adonis/Middleware/Auth',
ws_call_auth: 'App/Middleware/WsCallAuth',
};
Ws.registerGlobal(globalMiddleware).registerNamed(namedMiddleware);