The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

Hi guys!

I'm trying to make use of Godot 3.1's new websocket feature alongside with a very simple nodeJS server, the server example version of this package:

And godot's documentation for websocket client as listed here

I was able to succesfully connect the server and the engine itself.
But there are two problems annoying me that I have no clue on how to handle at this momment.

A. Is the way data gets inside the nodeJS server.

Whenever I transfer data from Godot to NodeJS WS Server I get weird characters even using JS's toString() function.


    var client = 
    func _sendData(data):
   _sendData("Hello World")

NodeJS Server

const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 5000 });
wss.on('connection', function connection(ws) {
  var socketAddr = ws._socket.remoteAddress.replace("::ffff:","");
  var connectedLogMsg = 'User Connected: ' + socketAddr + " - " + new Date();
  ws.on('message', function incoming(message) {
    message = message.toString();
    console.log('Data Received: ', message);
    wss.clients.forEach(function(client) {
      try {
        // var clientMessage = JSON.parse(message);        
      } catch (err) { err }

enter image description here

And B. Is how to handle players instances if not using High Level Multiplayer's Features

For instance, if we use HLM in godot we could easilly set up setnetworkmaster for the node and only that node would be "controllable" by the current player in the session.
However when I connect through Websocket with the second client, the first client is able to control both players at once. Is there any way to bypass this logic?

Thanks in advance.
Best regards from Brazil.

in Engine by (16 points)

1 Answer

+2 votes

I made a package for this : !!
You can find example here

by (32 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.