Skip to content

Commit

Permalink
fix socket
Browse files Browse the repository at this point in the history
  • Loading branch information
Giona Righini committed Aug 26, 2024
1 parent 2c738df commit 6f665f1
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"pigpio": "^3.3.1",
"rpio": "^2.4.2",
"socket.io": "^4.7.5",
"socket.io-client": "^4.7.5",
"telegraf": "^4.16.3",
"winston": "^3.12.0"
}
Expand Down
2 changes: 1 addition & 1 deletion src/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const buttonShutDown = new Gpio(pinShutDown, {
// SHARE
const server = http.createServer();
const io = new Server(server);
io.on("connection", () => {});
server.listen(3000, () => {});

const share = async () => {
pwmShare.hardwarePwmWrite(frequency, 20000);
Expand Down
19 changes: 19 additions & 0 deletions tests/socket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const http = require("http");
const { Server } = require("socket.io");
const server = http.createServer();
const io = new Server(server);

const ioc = require("socket.io-client");

server.listen(3000, () => {});
setTimeout(() => io.emit("test", 12), 2000);

const socket = ioc("http://localhost:3000");

socket.on("connect", () => {
console.log("connected!");
});

socket.on("test", (msg) => {
console.log("Received:", msg);
});
26 changes: 26 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,17 @@ [email protected]:
resolved "https://registry.yarnpkg.com/enabled/-/enabled-2.0.0.tgz#f9dd92ec2d6f4bbc0d5d1e64e21d61cd4665e7c2"
integrity sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ==

engine.io-client@~6.5.2:
version "6.5.4"
resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-6.5.4.tgz#b8bc71ed3f25d0d51d587729262486b4b33bd0d0"
integrity sha512-GeZeeRjpD2qf49cZQ0Wvh/8NJNfeXkXXcoGh+F77oEAgo9gUHwT1fCRxSNU+YEEaysOJTnsFHmM5oAcPy4ntvQ==
dependencies:
"@socket.io/component-emitter" "~3.1.0"
debug "~4.3.1"
engine.io-parser "~5.2.1"
ws "~8.17.1"
xmlhttprequest-ssl "~2.0.0"

engine.io-parser@~5.2.1:
version "5.2.3"
resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-5.2.3.tgz#00dc5b97b1f233a23c9398d0209504cf5f94d92f"
Expand Down Expand Up @@ -1408,6 +1419,16 @@ socket.io-adapter@~2.5.2:
debug "~4.3.4"
ws "~8.17.1"

socket.io-client@^4.7.5:
version "4.7.5"
resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-4.7.5.tgz#919be76916989758bdc20eec63f7ee0ae45c05b7"
integrity sha512-sJ/tqHOCe7Z50JCBCXrsY3I2k03iOiUe+tj1OmKeD2lXPiGH/RUCdTZFoqVyN7l1MnpIzPrGtLcijffmeouNlQ==
dependencies:
"@socket.io/component-emitter" "~3.1.0"
debug "~4.3.2"
engine.io-client "~6.5.2"
socket.io-parser "~4.2.4"

socket.io-parser@~4.2.4:
version "4.2.4"
resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-4.2.4.tgz#c806966cf7270601e47469ddeec30fbdfda44c83"
Expand Down Expand Up @@ -1697,3 +1718,8 @@ ws@~8.17.1:
version "8.17.1"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b"
integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==

xmlhttprequest-ssl@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.0.0.tgz#91360c86b914e67f44dce769180027c0da618c67"
integrity sha512-QKxVRxiRACQcVuQEYFsI1hhkrMlrXHPegbbd1yn9UHOmRxY+si12nQYzri3vbzt8VdTTRviqcKxcyllFas5z2A==

0 comments on commit 6f665f1

Please sign in to comment.