2020-04-04 04:08:12 +02:00
|
|
|
// lib/server.ts
|
|
|
|
import App from "./src/App";
|
2020-11-13 18:00:22 +01:00
|
|
|
import grpc from "grpc";
|
|
|
|
import {roomManager} from "./src/RoomManager";
|
|
|
|
import {IRoomManagerServer, RoomManagerService} from "./src/Messages/generated/messages_grpc_pb";
|
2020-12-14 22:43:05 +01:00
|
|
|
import {HTTP_PORT, GRPC_PORT} from "./src/Enum/EnvironmentVariable";
|
2020-11-13 18:00:22 +01:00
|
|
|
|
2020-12-14 22:43:05 +01:00
|
|
|
App.listen(HTTP_PORT, () => console.log(`WorkAdventure HTTP API starting on port %d!`, HTTP_PORT))
|
2020-11-13 18:00:22 +01:00
|
|
|
|
|
|
|
const server = new grpc.Server();
|
|
|
|
server.addService<IRoomManagerServer>(RoomManagerService, roomManager);
|
|
|
|
|
2020-12-14 22:43:05 +01:00
|
|
|
server.bind('0.0.0.0:'+GRPC_PORT, grpc.ServerCredentials.createInsecure());
|
2020-11-13 18:00:22 +01:00
|
|
|
server.start();
|
2020-12-14 22:43:05 +01:00
|
|
|
console.log('WorkAdventure HTTP/2 API starting on port %d!', GRPC_PORT);
|