Commit 95af560e authored by dm171558's avatar dm171558

Setup WebSocket Server

* Generate a Socket.io instance
* Add the Websockets to the Express Server
parent 15d7e05d
import * as Express from 'express';
import * as http from 'http';
import { WebSocket } from '../websockets';
import * as dotenv from 'dotenv';
import * as path from 'path';
export default class Server
{
private server: any;
private socket: WebSocket;
private app: Express;
constructor()
......@@ -13,6 +15,7 @@ export default class Server
dotenv.config();
this.app = new Express();
this.server = new http.Server(this.app);
this.socket = new WebSocket(this.server);
const port = process.env.SERVER_PORT || 3000;
const rootPath = path.dirname(require.main.filename);
......
export { WebSocket } from './socket';
\ No newline at end of file
import * as IO from 'socket.io';
export class WebSocket
{
private socket: any;
constructor(server: any)
{
this.socket = IO(server);
this.attachListeners();
}
private attachListeners(): void
{
this.socket.on('connection', (socket) =>
{
});
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment