aboutsummaryrefslogtreecommitdiff
path: root/client/multiplayer.gd
diff options
context:
space:
mode:
Diffstat (limited to 'client/multiplayer.gd')
-rw-r--r--client/multiplayer.gd11
1 files changed, 11 insertions, 0 deletions
diff --git a/client/multiplayer.gd b/client/multiplayer.gd
index 26614b14..3ee303ee 100644
--- a/client/multiplayer.gd
+++ b/client/multiplayer.gd
@@ -28,6 +28,12 @@ var socket := WebSocketPeer.new()
func _ready():
print("Multiplayer connect");
socket.inbound_buffer_size = 1024 * 1024 * 4
+
+ var keep_alive := Timer.new()
+ add_child(keep_alive)
+ keep_alive.wait_time = 1.
+ keep_alive.timeout.connect(send_keep_alive)
+ keep_alive.start()
func connect_to_url(url):
socket.connect_to_url(url)
@@ -156,6 +162,11 @@ func send_ready():
"type": "ready"
})
+func send_keep_alive() -> void:
+ send_packet({
+ "type": "keep_alive"
+ })
+
func send_packet(p):
var json = JSON.stringify(p)
if socket.get_ready_state() != WebSocketPeer.State.STATE_OPEN: