summaryrefslogtreecommitdiff
path: root/network/WebSocketTest.gd
blob: 49520dd6cbffb648a1af7eb334b3baf096cfc550 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
extends Node

onready var client = $WebSocketClient
var sent = false

func _ready():
	client.sock_connect_to_url("ws://127.0.0.1:8181")

func _process(_delta):
	if client.state == 2 and not sent:
		client.send("test string".to_utf8(), true)
		client.send(JSON.print({"items" : [1, "test_dictionary"]}).to_utf8(), true)
		sent = true
	if client.state == 2:
		var message = client.receive()
		if message:
			print(message)