Monday, 29 May 2017

How to connect to NodeJS database from unity?

I created a meteor app that would store user's data for me. Now that it has all the methods I need, I'm ready to use it in Unity. I uploaded the Meteor app to my ngnx server (but first packaged it as nodejs) and it works fine. However, I can't seem to figure out how to connected to it from Unity. I tried using WebSocket-Sharp but it doesn't connect...

Even if I was able to establish a connection, I have no idea how I would call methods from server or retrieve data from the database.

I took this straight out of the Websocket-Sharp example.

`using (var ws = new WebSocket("wss://lennyparisi.com/websocket"))
 {
    ws.OnMessage += (sender, e) =>
    {
        Debug.Log("Server says: " + e.Data);
    }; 
    ws.OnOpen += (sender, e) => 
    {
        Debug.Log("connectd");
    };
    ws.Connect();
}`



via Leonard Parisi

No comments:

Post a Comment