Skip to content
This repository has been archived by the owner on Sep 27, 2021. It is now read-only.

Latest commit

 

History

History
37 lines (25 loc) · 621 Bytes

instructions.md

File metadata and controls

37 lines (25 loc) · 621 Bytes

Register provider

The provider must be registered inside start/app.js file.

const providers = [
  '@adonisjs/websocket/providers/WsProvider'
]

Channels

The next step is to open start/socket.js and register websocket channels.

const Ws = use('Ws')

Ws.channel('chat', ({ socket }) => {
  console.log('new socket joined %s', socket.id)
})

Middleware

The middleware for websocket are kept in the start/wsKernel.js file.

const Ws = use('Ws')

const globalMiddleware = []
const namedMiddleware = {}

Ws
  .registerGlobal(globalMiddleware)
  .registerNamed(namedMiddleware)