Main.gd 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. extends Control
  2. const IntPoint = preload("IntPoint.gd")
  3. const IntPointClient = preload("Client_IntPointService.gd")
  4. const IntPointService = preload("Loader_proto_gorm.gd")
  5. onready var intPointClient = IntPointClient.new()
  6. onready var intPointService = IntPointService.new()
  7. # Declare member variables here. Examples:
  8. # var a = 2
  9. # var b = "text"
  10. # Called when the node enters the scene tree for the first time.
  11. func _ready():
  12. Messaging.subscribe("/websocket/closed", self, "_on_disconnected")
  13. Messaging.subscribe("/websocket/connected", self, "_on_connected")
  14. Messaging.subscribe("/IntPointService/Read", self, "_on_read")
  15. # Called every frame. 'delta' is the elapsed time since the previous frame.
  16. #func _process(delta):
  17. # pass
  18. func _on_read(Out):
  19. print("response to read: ", Out)
  20. func _on_connected(proto = ""):
  21. print("main connected")
  22. get_node("VBoxContainer/HSplitContainer/Reconnect").text = "~"
  23. func _on_disconnected(proto = ""):
  24. print("main disconnected")
  25. get_node("VBoxContainer/HSplitContainer/Reconnect").text = "x"
  26. func _on_Reconnect_pressed():
  27. Websocket.reconnect()
  28. func _on_GetIntPoint_pressed():
  29. var readRequest = intPointService.ReadIntPointRequest.new()
  30. readRequest.Id = 2
  31. intPointClient.Read(readRequest)
  32. func _on_CreateIntPoint_pressed():
  33. var createIntPointRequest = intPointService.CreateIntPointRequest.new()
  34. createIntPointRequest.Payload = intPointService.IntPoint.new()
  35. createIntPointRequest.Payload.Id = 2
  36. createIntPointRequest.Payload.X = 20
  37. createIntPointRequest.Payload.Y = 30
  38. intPointClient.Create(createIntPointRequest)
  39. func _on_UpdateIntPoint_pressed():
  40. var updateIntPointRequest = intPointService.UpdateIntPointRequest.new()
  41. updateIntPointRequest.Payload = intPointService.IntPoint.new()
  42. updateIntPointRequest.Payload.Id = 2
  43. updateIntPointRequest.Payload.X = 50
  44. updateIntPointRequest.Payload.Y = 80
  45. intPointClient.Update(updateIntPointRequest)
  46. func _on_DeleteIntPoint2_pressed():
  47. var deleteIntPointRequest = intPointService.DeleteIntPointRequest.new()
  48. deleteIntPointRequest.Id = 2
  49. intPointClient.Delete(deleteIntPointRequest)