Last active
June 14, 2022 20:01
-
-
Save malikdoksoz/97958d976ddab6f53a0612ddb2db044a to your computer and use it in GitHub Desktop.
AdonisJS 5 WebSocket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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