+1 vote

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

 _client.get_peer(1).put_packet("Test packet".to_utf8()) 

It is received as Binary Fin = true , buffer = 11
Shouldn't it be a Text Frame?

in Engine by (42 points)

2 Answers

0 votes
func send_dados(a:int,b:int):
    var temp:Array = [a,b]
    var t0 = var2bytes(temp)
    var t1 = t0.compress(3)

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.

by (215 points)

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]


func Dados(id):
    var t = Servidor.get_peer(id).get_var()

Due to standard websocket limitations, I also use this in _ready:


Obs: Servidor is one WebSocketServer (var Servidor = WebSocketServer.new())

+1 vote

It looks like the default write mode for the peer is Binary.

You can change this with:

by (20 points)

This answer is gold!!!

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.