Client_IntPointService.gd 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. extends Node
  2. const WSMessage = preload("WSMessage.gd")
  3. const IntPoint = preload("IntPoint.gd")
  4. const CreateIntPointRequest = preload("CreateIntPointRequest.gd")
  5. const CreateIntPointResponse = preload("CreateIntPointResponse.gd")
  6. const ReadIntPointRequest = preload("ReadIntPointRequest.gd")
  7. const ReadIntPointResponse = preload("ReadIntPointResponse.gd")
  8. const UpdateIntPointRequest = preload("UpdateIntPointRequest.gd")
  9. const UpdateIntPointResponse = preload("UpdateIntPointResponse.gd")
  10. const UpdateSetIntPointRequest = preload("UpdateSetIntPointRequest.gd")
  11. const UpdateSetIntPointResponse = preload("UpdateSetIntPointResponse.gd")
  12. const DeleteIntPointRequest = preload("DeleteIntPointRequest.gd")
  13. const DeleteIntPointsRequest = preload("DeleteIntPointsRequest.gd")
  14. const DeleteIntPointResponse = preload("DeleteIntPointResponse.gd")
  15. # connects the service to messaging system and websocket
  16. func _init():
  17. Messaging.registerPublisher("/IntPointService/Create", self, "Create")
  18. Websocket.registerReceiver("IntPointService:Create", self)
  19. Messaging.subscribe("/IntPointService/do_Create", self, "Create")
  20. Messaging.registerPublisher("/IntPointService/Read", self, "Read")
  21. Websocket.registerReceiver("IntPointService:Read", self)
  22. Messaging.subscribe("/IntPointService/do_Read", self, "Read")
  23. Messaging.registerPublisher("/IntPointService/Update", self, "Update")
  24. Websocket.registerReceiver("IntPointService:Update", self)
  25. Messaging.subscribe("/IntPointService/do_Update", self, "Update")
  26. Messaging.registerPublisher("/IntPointService/Delete", self, "Delete")
  27. Websocket.registerReceiver("IntPointService:Delete", self)
  28. Messaging.subscribe("/IntPointService/do_Delete", self, "Delete")
  29. func receive(target, Out):
  30. match target:
  31. "IntPointService:Create":
  32. emit_signal("Create", Out)
  33. "IntPointService:Read":
  34. emit_signal("Read", Out)
  35. "IntPointService:Update":
  36. emit_signal("Update", Out)
  37. "IntPointService:Delete":
  38. emit_signal("Delete", Out)
  39. signal Create(Out)
  40. func Create(In : CreateIntPointRequest):
  41. Websocket.send("POST","/v1/point",{"payload": In.Payload}, "IntPointService:Create")
  42. signal Read(Out)
  43. func Read(In : ReadIntPointRequest):
  44. Websocket.send("GET","/v1/point/"+str(In.Id),{"id": In.Id,"fields": In.Fields}, "IntPointService:Read")
  45. signal Update(Out)
  46. func Update(In : UpdateIntPointRequest):
  47. Websocket.send("PATCH","/v1/point/"+str(In.Payload.Id),{"payload": In.Payload,"gerogeriGegege": In.GerogeriGegege}, "IntPointService:Update")
  48. signal Delete(Out)
  49. func Delete(In : DeleteIntPointRequest):
  50. Websocket.send("DELETE","/v1/point/"+str(In.Id),{"id": In.Id}, "IntPointService:Delete")