generator
generator copied to clipboard
[FEATURE] GDscript Generator Template
Why do we need this improvement?
It would be great to also have a template for generating GDScript code. Godot/Redot has a Built-in Web socket handler, so I guess that the Template shouldn't be to hard to write. Though I don't know about the other protocols which AsyncAPI supports
OAS also has a Generator for GDScript, but OAS can't be used for Web sockets, that's why I'm suggesting it here.
How will this change help?
Games tend to use a Combination of REST and Web sockets for Communications, This would allow creating a Spec for the Communication of your Games Client and Server, and generate interfaces, data struct and similar for both sides.
Screenshots
No response
How could it be implemented/designed?
https://docs.redotengine.org/en/stable/tutorials/networking/websocket.html
here is an example, of a web socket connection, which is listening for responses (In this case unixtime-stamps) and setting them as the content of a text Node:
extends RichTextLabel
# docs.redotengine.org/en/stable/tutorials/networking/websocket.html
@export var websocket_url = "ws://localhost:8080/ws/server"
var socket = WebSocketPeer.new()
func _ready() -> void:
var err = socket.connect_to_url(websocket_url)
if err != OK:
error_string(err)
set_process(false)
func _process(_delta: float) -> void:
socket.poll()
var state = socket.get_ready_state()
if state == WebSocketPeer.STATE_CLOSED:
print(socket.get_close_reason())
self.text = "Disconnected"
return
if state == WebSocketPeer.STATE_OPEN:
while socket.get_available_packet_count():
self.text = "Current Unixtime: " + socket.get_packet().get_string_from_utf8()
🚧 Breaking changes
No
👀 Have you checked for similar open issues?
- [x] I checked and didn't find a similar issue
🏢 Have you read the Contributing Guidelines?
- [x] I have read the Contributing Guidelines
Are you willing to work on this issue?
Yes, but only if my personal schedule allows me to