Skip to content

Jagtap01sumit/Chatapp-Backend

Repository files navigation

Basic setup for socket.io

import { Server } from "socket.io"; import http from "http"; import express from "express";

const app = express(); const server = http.createServer(app); const io = new Server(server, { cors: { origin: ["http://localhost:3000"], methods: ["GET", "POST"], }, });

io.on("connection", (socket) => { console.log("a user connected", socket.id); });

//socket.on () is used to listen to the envents. can be used both client and server side socket.on("connection", (socket) => { console.log("user disconnected", socket.id); }); export { app, io, server };

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published