Kaydet (Commit) 186f6db8 authored tarafından Abdülkerim AKSAK's avatar Abdülkerim AKSAK

bagımlılıklar kuruldu/server kontrol edildi

üst 701490f6
This diff is collapsed.
......@@ -10,6 +10,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"electron": "^12.0.4"
"electron": "^12.0.4",
"socket.io-client": "^4.0.1"
}
}
//client
const io = require("socket.io-client");
//Connect
let game = io.connect("http://localhost:3030/game");
game.on("welcome", (data) => {
console.log(data);
});
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "socketioserver",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"nodemon": "^2.0.7",
"socket.io": "^4.0.1"
}
}
// Server Side
const express = require("express");
const app = express();
const port = 3030;
const http = require("http").createServer();
const io = require("socket.io")(http);
io.of("/game").on("connection", (socket) => {
socket.emit("welcome", "hello to <namespcaess>");
});
http.listen(port, () => {
console.log(`Server is on http://localhost:${port}`);
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment