Showing
2 changed files
with
18 additions
and
2 deletions
1 | import express from "express"; | 1 | import express from "express"; |
2 | import socketIo, { Server as IoServer } from "socket.io"; | 2 | import socketIo, { Server as IoServer } from "socket.io"; |
3 | -import { createServer } from "http"; | 3 | +import { createServer } from "https"; |
4 | import { RoomManager } from "./room/RoomManager"; | 4 | import { RoomManager } from "./room/RoomManager"; |
5 | import { Connection } from "./connection/Connection"; | 5 | import { Connection } from "./connection/Connection"; |
6 | import { SocketIoWrapper } from "./connection/SocketWrapper"; | 6 | import { SocketIoWrapper } from "./connection/SocketWrapper"; |
7 | +import { readFileSync } from "fs"; | ||
7 | 8 | ||
8 | export class Server { | 9 | export class Server { |
9 | public readonly port: number; | 10 | public readonly port: number; |
... | @@ -13,7 +14,20 @@ export class Server { | ... | @@ -13,7 +14,20 @@ export class Server { |
13 | this.port = port; | 14 | this.port = port; |
14 | 15 | ||
15 | const app = express(); | 16 | const app = express(); |
16 | - const server = createServer(app); | 17 | + const server = createServer( |
18 | + { | ||
19 | + cert: readFileSync( | ||
20 | + "/etc/letsencrypt/live/2020105578.oss2021.tk/cert.pem" | ||
21 | + ), | ||
22 | + key: readFileSync( | ||
23 | + "/etc/letsencrypt/live/2020105578.oss2021.tk/privkey.pem" | ||
24 | + ), | ||
25 | + ca: readFileSync( | ||
26 | + "/etc/letsencrypt/live/2020105578.oss2021.tk/fullchain.pem" | ||
27 | + ), | ||
28 | + }, | ||
29 | + app | ||
30 | + ); | ||
17 | this.io = new socketIo.Server(server, { | 31 | this.io = new socketIo.Server(server, { |
18 | cors: { | 32 | cors: { |
19 | origin: "*", | 33 | origin: "*", | ... | ... |
-
Please register or login to post a comment