🔧 Added hostname inference for socket server
This commit is contained in:
@@ -5,7 +5,11 @@ import { logger } from "../utils/logger.utils";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { IExtractionOptions, IFolderData } from "threetwo-ui-typings";
|
import { IExtractionOptions, IFolderData } from "threetwo-ui-typings";
|
||||||
import IO from "socket.io";
|
import { createServer } from "http";
|
||||||
|
import { Server } from "socket.io";
|
||||||
|
|
||||||
|
const socketServer = createServer();
|
||||||
|
const SOCKET_HOST = process.env.DOCKER_HOST || `localhost`;
|
||||||
export default class ApiService extends Service {
|
export default class ApiService extends Service {
|
||||||
public constructor(broker: ServiceBroker) {
|
public constructor(broker: ServiceBroker) {
|
||||||
super(broker);
|
super(broker);
|
||||||
@@ -92,7 +96,8 @@ export default class ApiService extends Service {
|
|||||||
started(): any {
|
started(): any {
|
||||||
// Socket gateway-ish
|
// Socket gateway-ish
|
||||||
// Create a Socket.IO instance, passing it our server
|
// Create a Socket.IO instance, passing it our server
|
||||||
this.io = new IO.Server(3001);
|
socketServer.listen(3001, SOCKET_HOST);
|
||||||
|
this.io = new Server(socketServer, {});
|
||||||
|
|
||||||
// Add a connect listener
|
// Add a connect listener
|
||||||
this.io.on("connection", (client) => {
|
this.io.on("connection", (client) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user