Hi,
I have this NodeJS-Socket.io server (socket.io@2.5.0):
import Server from "socket.io"
const io = new Server(3000)
io.on("connection", (socket) => console.log("connection"))
setInterval(() => { console.log("emit hi"); io.sockets.emit("hi", "everyone")}, 5000)
and this code in a MonoBehaviour:
async void Start()
{
Uri uri = new Uri("http://localhost:3000");
SocketIOUnity socket = new SocketIOUnity(uri, new SocketIOOptions
{
Transport = SocketIOClient.Transport.TransportProtocol.WebSocket
});
await socket.ConnectAsync();
socket.On("hi", (response) =>
{
print(response);
});
}
When the project in Unity starts, it apparenty connects (server outputs "connection" twice!!!), but no response can be seen in Unity.
OTOH, with this client (socket.io-client@2.5.0):
Hi, I have this NodeJS-Socket.io server (socket.io@2.5.0):
and this code in a MonoBehaviour:
When the project in Unity starts, it apparenty connects (server outputs "connection" twice!!!), but no response can be seen in Unity. OTOH, with this client (socket.io-client@2.5.0):
it works as expected (only one "connection" in server, "everyone" in client).
Furthermore, with a server based on socket.io v4 (only change in import), the same Unity code works fine.
Unfortunately I need to connect to v2 server api :-/