-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
198 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
import express, { type Application } from 'express' | ||
import { createServer } from 'http' | ||
import { Server } from 'socket.io' | ||
import ws from 'ws' | ||
import { Event } from './events.js' | ||
import eiows from 'node_modules/eiows/dist/eiows.js' | ||
|
||
export class SocketController { | ||
protected readonly app: Application | ||
public server | ||
static io: Server | ||
|
||
constructor () { | ||
constructor() { | ||
this.app = express() | ||
this.server = createServer(this.app) | ||
SocketController.io = new Server(this.server, { path: '/socket.io' }) | ||
SocketController.io = new Server(this.server, { | ||
path: '/socket.io', | ||
wsEngine: process.platform !== 'win32' ? eiows.Server : ws.Server | ||
}) | ||
} | ||
|
||
listen (port: string) { | ||
listen(port: string) { | ||
this.server.listen(port, () => { | ||
console.log(`🚀 Servidor inicializado na porta ${port}`) | ||
}) | ||
} | ||
|
||
ready () { | ||
ready() { | ||
SocketController.io.on('connection', async (client) => new Event({ client }).controller()) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.