I am searching for a way to create a unity3d game with a node.js server. I am familiar with Socket.io so I wanted to use that.
I got "UnitySocket-IO" but it doesn't work, It says:
Error initializing handshake with http://localhost:80/
My code on the client (Unity) is:
#pragma strict
var client:SocketIOClient.Client = new SocketIOClient.Client("http://localhost:80/");
function Start () {
//client.Opened += SocketOpened;
client.Message += SocketMessage;
//client.SocketConnectionClosed += SocketConnectionClosed;
client.Error +=SocketError;
client.Connect();
}
function SocketMessage(sender, e) {
client.Send("Pong");
}
function SocketError(sender, e:SocketIOClient.ErrorEventArgs) {
Debug.Log(e.Message);
}
The code on the server (Node.JS):
var io = require('socket.io')();
io.listen(80);
io.on("connection", function (socket) {
"use strict";
console.log("Connected!");
setTimeout(function () {
console.log("Sent ping.");
socket.emit("Ping!");
}, 2000);
io.on("message", function (data) {
console.log(data);
});
});
I suspect this is a problem between 1.0 and the unitysocket-io library. Is there any alternative that works in Unityscript?
I tried downgrading to 0.9, but it still doesn't work, and I want to use current versions of things. Thanks!