i am writing a webapp that is built with electron(1.4.13) and p5js.
this webapp has a multi edit system that lets multiple users to edit the same document (like google docs). however i am having a isue where the socket server refuses conections to the p5js electron enviroment
error: polling-xhr.js:157 GET http://:5000/socket.io/?EIO=4&transport=polling&t=NyB7FTE net::ERR_CONNECTION_REFUSED
server.js:
const express = require('express');
class server {
constructor(port) {
this.port = port;
this.app = express();
this.http = require('http').Server(this.app);
this.io = require('socket.io')(this.http);
this.http.listen(port, () => console.log(`Hosted on port ${port}`));
this.io.on('connection', function(socket) {
console.log('A user connected');
socket.on('disconnect', function () {
console.log('A user disconnected');
});
});
}
}
let _server = new server(5000);
client.js:
class client {
constructor(host,port,onmessage) {
this.socket = io("http://"+host+":"+port);//"ws://"+
this.socket.on("message", data => {
onmessage(data);
});
}
disconect() {
this.socket
}
write(ipda) {
this.socket.send(ipda)
}
}
let _client = new client('MY IP ADDRESS FOR TEST',5000,() => {console.log(data)});
index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Thinkin Box</title>
<script language="javascript" type="text/javascript" src="libraries/p5.js"></script>
<!--<script language="javascript" src="libraries/p5.dom.js"></script>-->
<!--<script language="javascript" src="libraries/p5.sound.js"></script>-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.4.1/socket.io.js"></script>
<script language="javascript" type="text/javascript" src="sketch.js"></script>
<style> body {padding: 0; margin: 0; background: #000000; overflow-x:hidden; overflow-y: hidden} </style>
</head>
<body>
</body>
<script>
// You can also require other files to run in this process
require('../renderer.js')
</script>
</html>