1

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();
}`
Leonard Parisi
  • 200
  • 1
  • 3
  • 12

1 Answers1

0

If you are connecting to a Meteor backend then you can find a pre-existing ddp library instead of trying to handle it on the web socket level.

Perhaps https://github.com/green-coder/unity3d-ddp-client or https://github.com/hiddenswitch/Meteor-Unity both have functions for calling a meteor method.

Also, ensure your server can be reached. Try pulling up the meteor server in your browser. Double check the port. I know that a lot of development meteor servers use 3000 by default. wss://lennyparisi.com:3000/websocket

Travis White
  • 1,977
  • 1
  • 11
  • 19
  • I tried using the Meteor-Unity SDK, but it wouldn't connect. I thought that it wasnt connecting because it was trying to connect to a meteor server (and my server is now in nodejs form), but I think that it's actually because the "wss://lennyparisi.com/websocket" cannot be reached (regardless of the SDK). What do you think @TravisWhite ? Do you think it matters? Should I be focusing on getting a connecting to the websocket instead? – Leonard Parisi May 30 '17 at 01:55
  • I can access the server just fine at lennyparisi.com. Meteor uses websockets for it's ddp connection. I'm not sure you need a websocket connection for a simple nodejs form. You could use fetch with GET and POST to call the api server as needed without a web socket connection. You will have to sort authentication out for each api request. – Travis White May 30 '17 at 15:05