Compare commits
2 commits
25296ae38d
...
4f949a7239
| Author | SHA1 | Date | |
|---|---|---|---|
| 4f949a7239 | |||
| 9457488fa7 |
2 changed files with 13 additions and 10 deletions
|
|
@ -74,13 +74,16 @@ func set_variable(name: String, value: Variant, button_id: String = "") -> bool:
|
|||
last_error_description = response.error_message
|
||||
return false
|
||||
|
||||
func delete_variable(name: String, button_id) -> bool:
|
||||
var api_path: String = "/api" % name
|
||||
func delete_variable(name: String, button_id: String = "") -> bool:
|
||||
var api_path: String = "/api"
|
||||
var req: Dictionary = {
|
||||
"request": "deleteVariable",
|
||||
"name": name,
|
||||
"buttonID": button_id
|
||||
"name": name
|
||||
}
|
||||
|
||||
if button_id != "":
|
||||
req["buttonID"] = button_id
|
||||
|
||||
client.request(SammiClient.Method.POST, api_path, JSON.stringify(req))
|
||||
var response: SammiClient.SammiResponse = await client.request_completed
|
||||
if response.code == 200:
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ func request(method: Method, api_path: String, body: String) -> void:
|
|||
|
||||
self.query = api_path
|
||||
self.body = body
|
||||
self.method = method
|
||||
self.client = StreamPeerTCP.new()
|
||||
self.client.connect_to_host(host, port)
|
||||
self.state = State.CONNECTING
|
||||
|
|
@ -51,11 +52,6 @@ func _process(_delta: float) -> void:
|
|||
if not client:
|
||||
return
|
||||
|
||||
if state == State.CLOSED:
|
||||
client.disconnect_from_host()
|
||||
client = null
|
||||
return
|
||||
|
||||
client.poll()
|
||||
if client.get_status() == StreamPeerTCP.Status.STATUS_CONNECTED and state == State.CONNECTING:
|
||||
state = State.REQUESTING
|
||||
|
|
@ -130,8 +126,12 @@ func _read_response() -> void:
|
|||
buffer.append_array(chunk[1])
|
||||
else:
|
||||
response = SammiResponse.new(headers, buffer, query)
|
||||
request_completed.emit(response)
|
||||
state = State.CLOSED
|
||||
headers = []
|
||||
buffer = []
|
||||
client.disconnect_from_host()
|
||||
client = null
|
||||
request_completed.emit(response)
|
||||
|
||||
|
||||
class SammiResponse:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue