Vote count:
0
I'm making a multiplayer game using nodejs with socket.io.
When I'm working on my laptop where the nodejs is running, everything works. I can open multiple window tabs and I have multiple users.
But when I'm trying to connect to my local ip (from the node server) from another laptop next to me, I get an error with the socket.io
"GET http://localhost:8000/socket.io/socket.io.js net::ERR_CONNECTION_REFUSED"
code
/**************************************************
** GAME INITIALISATION
**************************************************/
function init() {
// Declare the canvas and rendering context
canvas = document.getElementById("gameCanvas");
ctx = canvas.getContext("2d");
// Maximise the canvas
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
// Initialise keyboard controls
keys = new Keys();
// Calculate a random start position for the local player
// The minus 5 (half a player size) stops the player being
// placed right on the egde of the screen
var startX = Math.round(Math.random()*(canvas.width-5)),
startY = Math.round(Math.random()*(canvas.height-5));
// Initialise the local player
localPlayer = new Player(startX, startY);
socket = io.connect("http://localhost", {port: 8000, transports: ["websocket"]});
remotePlayers = [];
// Start listening for events
setEventHandlers();
};
**************************************************
** GAME INITIALISATION
**************************************************/
function init() {
// Declare the canvas and rendering context
canvas = document.getElementById("gameCanvas");
ctx = canvas.getContext("2d");
// Maximise the canvas
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
// Initialise keyboard controls
keys = new Keys();
// Calculate a random start position for the local player
// The minus 5 (half a player size) stops the player being
// placed right on the egde of the screen
var startX = Math.round(Math.random()*(canvas.width-5)),
startY = Math.round(Math.random()*(canvas.height-5));
// Initialise the local player
localPlayer = new Player(startX, startY);
socket = io.connect("http://localhost", {port: 8000, transports: ["websocket"]});
remotePlayers = [];
// Start listening for events
setEventHandlers();
};
asked 53 secs ago
err_connection_refused using socket.IO
Aucun commentaire:
Enregistrer un commentaire