mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Replace XML codeblock spaces with tabs
This commit is contained in:
@@ -14,22 +14,22 @@
|
||||
var socket = WebSocketPeer.new()
|
||||
|
||||
func _ready():
|
||||
socket.connect_to_url("wss://example.com")
|
||||
socket.connect_to_url("wss://example.com")
|
||||
|
||||
func _process(delta):
|
||||
socket.poll()
|
||||
var state = socket.get_ready_state()
|
||||
if state == WebSocketPeer.STATE_OPEN:
|
||||
while socket.get_available_packet_count():
|
||||
print("Packet: ", socket.get_packet())
|
||||
elif state == WebSocketPeer.STATE_CLOSING:
|
||||
# Keep polling to achieve proper close.
|
||||
pass
|
||||
elif state == WebSocketPeer.STATE_CLOSED:
|
||||
var code = socket.get_close_code()
|
||||
var reason = socket.get_close_reason()
|
||||
print("WebSocket closed with code: %d, reason %s. Clean: %s" % [code, reason, code != -1])
|
||||
set_process(false) # Stop processing.
|
||||
socket.poll()
|
||||
var state = socket.get_ready_state()
|
||||
if state == WebSocketPeer.STATE_OPEN:
|
||||
while socket.get_available_packet_count():
|
||||
print("Packet: ", socket.get_packet())
|
||||
elif state == WebSocketPeer.STATE_CLOSING:
|
||||
# Keep polling to achieve proper close.
|
||||
pass
|
||||
elif state == WebSocketPeer.STATE_CLOSED:
|
||||
var code = socket.get_close_code()
|
||||
var reason = socket.get_close_reason()
|
||||
print("WebSocket closed with code: %d, reason %s. Clean: %s" % [code, reason, code != -1])
|
||||
set_process(false) # Stop processing.
|
||||
[/gdscript]
|
||||
[/codeblocks]
|
||||
To use the peer as part of a WebSocket server refer to [method accept_stream] and the online tutorial.
|
||||
|
||||
Reference in New Issue
Block a user