cordis/server-test/server.ts

23 lines
606 B
TypeScript

import * as https from 'https';
import * as path from 'path';
import * as fs from 'fs';
import * as socketio from 'socket.io';
const server = https.createServer({
cert: fs.readFileSync(path.join(__dirname, '../../server-test/ssl/cert.pem')).toString(),
key: fs.readFileSync(path.join(__dirname, '../../server-test/ssl/key.pem')).toString(),
});
const io = new socketio.Server(server);
io.on('connection', (socket: socketio.Socket) => {
socket.on('hello', (message: string) => {
console.log('got a hello :)');
socket.emit('exde');
});
});
server.listen(4040);
console.log('listening on 4040');