Skip to content

Instantly share code, notes, and snippets.

@malikdoksoz
Last active June 14, 2022 20:01
Show Gist options
  • Save malikdoksoz/97958d976ddab6f53a0612ddb2db044a to your computer and use it in GitHub Desktop.
Save malikdoksoz/97958d976ddab6f53a0612ddb2db044a to your computer and use it in GitHub Desktop.
AdonisJS 5 WebSocket
import { WebSocketServer } from 'ws'
import AdonisServer from '@ioc:Adonis/Core/Server'
class Ws {
public wss: WebSocketServer
private booted = false
public boot() {
/**
* Ignore multiple calls to the boot method
*/
if (this.booted) {
return
}
this.booted = true
this.wss = new WebSocketServer({ server: AdonisServer.instance! })
console.log("WebSocket Server Started!!");
}
}
export default new Ws()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment