Unity3d programımı node.js sunucusu ile bağlamak için socket.io kullanmaya çalışıyorum.Node.js ile Unity3d Bağlama
UnitySocketIO'yu kullanarak istemci ve sunucu arasındaki bağlantıyı başardım.
Ancak, On veya Emit yöntemi çalışmaz.
Birisi bana bu problemde yardımcı olabilir mi?
void Start() {
string socketUrl = "http://127.0.0.1:50122";
Debug.Log("socket url: " + socketUrl);
this.socket = new Client(socketUrl);
this.socket.Opened += this.SocketOpened;
this.socket.Message += this.SocketMessage;
this.socket.SocketConnectionClosed += this.SocketConnectionClosed;
this.socket.Error += this.SocketError;
this.socket.Connect();
}
private void SocketOpened (object sender, EventArgs e) {
Debug.Log("socket opened"); // i got this message
this.socket.On ("message", (data) => {
Debug.Log ("message : " + data);
});
this.socket.Emit("join", "abc");
Debug.Log("Emit done"); // i got this message
}
....
Sizin olay muhtemelen yanlış sırada ekliio.sockets.on('connection', function (socket) {
console.log('connect'); // i got this message
socket.emit('message', 'Hello World!');
socket.on('join', function (id) {
console.log('client joined with id ' + id);
socket.emit('message', 'Hello ' + id);
});
});
Çalışıyor musunuz? Bu kendimle mücadele. – Jeff
Sonunda bunu çözdünüz mü? UnitySocketIO'nun dll dosyalarını nereye koydunuz? – Nikola
@Nikola, dll dosyalarını Assets klasörünüzün herhangi bir yerine koyun. Sonra (C# için) komut dosyasına sadece 'SocketIOClient;' kullanarak ekleyin. Ben javascript için eşdeğer ne olduğundan emin değilim ama anlamaya zor olamaz. – Harrison