wrapper.gd 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. extends Node2D
  2. class_name Matrix
  3. # Declare member variables here. Examples:
  4. # var a = 2
  5. # var b = "text"
  6. var python_client = null
  7. var client_class = load("res://client.py")
  8. # Called when the node enters the scene tree for the first time.
  9. func _ready():
  10. pass # Replace with function body.
  11. func init_client(server,username):
  12. python_client = client_class.new()
  13. python_client.homeserver = server
  14. python_client.username = username
  15. add_child(python_client)
  16. func register(password):
  17. python_client.register(password)
  18. return true
  19. func login(password):
  20. return python_client.login2(password)
  21. func get_username():
  22. return str(python_client.username)
  23. func get_homeserver():
  24. return str(python_client.homeserver).trim_prefix("https://").trim_prefix("http://")
  25. func create_if_not(room_name):
  26. return python_client.create_if_not2(room_name)
  27. func join(room_id_or_alias): #returns id
  28. return str(python_client.join2(room_id_or_alias))
  29. func synchronize():
  30. python_client.get_first_batch()
  31. #func fetch_new(room_id):
  32. # python_client.fetch_new_messages(room_id)
  33. func fetch_one():
  34. return str(python_client.fetch_one())
  35. func start_listen(room_id):
  36. python_client.start_listen(room_id)
  37. func reset():
  38. if python_client:
  39. python_client.queue_free()
  40. # Called every frame. 'delta' is the elapsed time since the previous frame.
  41. #func _process(delta):
  42. # pass