Topic was automatically imported from the old Question2Answer platform.
Asked By
Nikola-Milovic
So I am not too sure about this, but I have a websocket Ktor Kotlin server, which receives frames. So I’ve tested sending a frame to the Godot Client and I successfully receive it, but whenever I send a packet with
func send_dados(a:int,b:int):
var temp:Array = [a,b]
var t0 = var2bytes(temp)
var t1 = t0.compress(3)
Client.get_peer(1).put_packet(t1)
func Dados(id):
var t = Servidor.get_peer(id).get_packet()
var dados_temp = t.decompress(32000000,3)
var temp = bytes2var(dados_temp)
with these two functions I can send anything inside this temp array.
in the send_dados function I am using two int, the first to identify the reason for that package, and the second can be anything.
I use compression because in one of my projects I have to send images inside the package, and the limits of the websocket are a bit narrow. otherwise, just:
func send_dados(a:int,b:int):
var temp:Array = [a,b]
Client.get_peer(1).put_var(temp)
Server:
func Dados(id):
var t = Servidor.get_peer(id).get_var()
Due to standard websocket limitations, I also use this in _ready:
Servidor.set_buffers(1024,32,1024,32)
Obs: Servidor is one WebSocketServer (var Servidor = WebSocketServer.new())