Virtual method not being called

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By PerduGames
:warning: Old Version Published before Godot 3 was released.

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())
:bust_in_silhouette: Reply From: PerduGames

I can understand what is happening.

It is calling the “_put_packet()” method of the “PacketPeer” class which has the name in GDScript “put_packet()” which is the method we call:

"ClassDB::bind_method(D_METHOD(“put_packet”, “buffer”), &PacketPeer::_put_packet);

then “_put_packet()” calls the “put_packet_buffer()” method:

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

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