This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Godot 3:

I'm trying to use this method here: https://github.com/godotengine/godot/blob/master/modules/enet/networked_multiplayer_enet.cpp#L403
but I get error expected 1 arguments.

What is happening is that you are probably calling the "PacketPeer" class method instead of the "put_packet()" virtual method of the "NetworkedMultiplayerENet" class.

I realize that the method is not being called here:
https://github.com/godotengine/godot/blob/master/modules/enet/networked_multiplayer_enet.cpp#L654
I do not know if he should or should not, because if he should, I do not understand why he is not then.

Steps to reproduce:
Create a project with the script below on a node and run:

extends Node

const SERVER_IP = "127.0.0.1"
const SERVER_PORT = 1510
var socketUDP = NetworkedMultiplayerENet.new()

function _ready():
    start_client()
    send_bytes()

function start_client():
    socketUDP.create_client(SERVER_IP, SERVER_PORT)
    get_tree().set_network_peer(socketUDP)
    socketUDP.set_transfer_mode(socketUDP.TRANSFER_MODE_RELIABLE)

function send_bytes():
    var stg = "hello"
    var pac = stg.to_utf8()
    socketUDP.put_packet(pac, pac.size())
in Engine by (203 points)
edited by

1 Answer

0 votes
Best answer

I can understand what is happening.

It is calling the "putpacket()" method of the "PacketPeer" class which has the name in GDScript "put_packet()" which is the method we call:

"ClassDB::bindmethod(DMETHOD("putpacket", "buffer"), &PacketPeer::put_packet);

https://github.com/godotengine/godot/blob/bd282ff43f23fe845f29a3e25c8efc01bd65ffb0/core/io/packet_peer.cpp#L137

then "putpacket()" calls the "putpacketbuffer()" method:

https://github.com/godotengine/godot/blob/bd282ff43f23fe845f29a3e25c8efc01bd65ffb0/core/io/packet_peer.cpp#L71

that followed in "putpacketbuffer()" is called the "put_packet()" which because it is virtual, will call the method of the child class:

https://github.com/godotengine/godot/blob/bd282ff43f23fe845f29a3e25c8efc01bd65ffb0/core/io/packet_peer.cpp#L78

This will be called the "put_packet()" method of the "NetworkedMultiplayerENet" class.

by (203 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.