forked from OurProjectsCombined/chat-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Keagan Aromin
authored and
Keagan Aromin
committed
Jan 12, 2025
1 parent
bbd747c
commit 15b618c
Showing
3 changed files
with
26 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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("user has connected", socket.id); | ||
|
||
//socket.on is a listener for the events; can be used on both client and server side | ||
socket.on('disconnect', () => { | ||
console.log('user disconnected', socket.id) | ||
}) | ||
}) | ||
export {app, io, server} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters