Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ console.log = function() {
};

// 接收启动参数作为端口号,默认8081
const PORT = process.argv[2] || 8081;
const server = new WebSocket.Server({ port: PORT });
const HOST = process.argv[2] || "localhost"
const PORT = process.argv[3] || 8081;
const server = new WebSocket.Server({ port: PORT, host: HOST });

const SEND_TYPE_REG = '1001'; // 注册后发送用户id
const SEND_TYPE_ROOM_INFO = '1002'; // 发送房间信息
Expand All @@ -31,7 +32,7 @@ const RECEIVE_TYPE_KEEPALIVE = '9999'; // keep-alive
const RECEIVE_TYPE_UPDATE_NICKNAME = '9004'; // 更新昵称请求


console.log(`Signaling server running on ws://localhost:${PORT}`);
console.log(`Signaling server running on ws://${HOST}:${PORT}`);

server.on('connection', (socket, request) => {
const ip = request.headers['x-forwarded-for'] ?? request.headers['x-real-ip'] ?? socket._socket.remoteAddress.split("::ffff:").join("");
Expand Down
8 changes: 7 additions & 1 deletion www/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
const wsUrl = 'wss://fagedongxi.com/ws';
const PRTOCOL = 'wss'; // or ws: not use TLS
const HOST = 'fagedongxi.com'; // intermediate server host
const PORT = 443; // intermediate server port
const PATH = '/ws' // websocket path

// final wsUrl
const wsUrl = `${PRTOCOL}://${HOST}:${PORT}${PATH}`;

var users = [];
var me = new XChatUser();
Expand Down