Stuff & things.
This commit is contained in:
@@ -28,7 +28,13 @@ import { renderChat } from "./render.js";
|
|||||||
* @returns {{ socket: WebSocket, sendMessage: (content: string) => void }}
|
* @returns {{ socket: WebSocket, sendMessage: (content: string) => void }}
|
||||||
*/
|
*/
|
||||||
export function initWebSocket(username, chatEl, inputContainer, usersListEl) {
|
export function initWebSocket(username, chatEl, inputContainer, usersListEl) {
|
||||||
const socket = new WebSocket("ws://localhost:8080", "coms");
|
const socket = new WebSocket(
|
||||||
|
(location.protocol === "https:" ? "wss" : "ws") +
|
||||||
|
"://" +
|
||||||
|
location.host +
|
||||||
|
"/ws",
|
||||||
|
"coms",
|
||||||
|
);
|
||||||
|
|
||||||
socket.onopen = () => {
|
socket.onopen = () => {
|
||||||
// Announce join.
|
// Announce join.
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
const express = require("express");
|
const express = require("express");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const livereload = require("livereload");
|
const isDev = process.env.NODE_ENV !== "production";
|
||||||
const connectLivereload = require("connect-livereload");
|
let livereload, connectLivereload;
|
||||||
|
if (isDev) {
|
||||||
|
livereload = require("livereload");
|
||||||
|
connectLivereload = require("connect-livereload");
|
||||||
|
}
|
||||||
const app = express();
|
const app = express();
|
||||||
const PORT = 3000;
|
const PORT = 3000;
|
||||||
|
|
||||||
|
if (isDev) {
|
||||||
const liveReloadServer = livereload.createServer();
|
const liveReloadServer = livereload.createServer();
|
||||||
liveReloadServer.watch(path.join(__dirname, "public"));
|
liveReloadServer.watch(path.join(__dirname, "public"));
|
||||||
app.use(connectLivereload());
|
app.use(connectLivereload());
|
||||||
|
}
|
||||||
|
|
||||||
app.use(express.static("public"));
|
app.use(express.static("public"));
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#include "include/session.h"
|
#include "include/session.h"
|
||||||
|
|
||||||
#include <libwebsockets.h>
|
#include <libwebsockets.h>
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/ssl.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user