DBQueryRequestHandler.cs 768 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using ETModel;
  3. namespace ETHotfix
  4. {
  5. [MessageHandler(AppType.DB)]
  6. public class DBQueryRequestHandler : AMRpcHandler<DBQueryRequest, DBQueryResponse>
  7. {
  8. protected override void Run(Session session, DBQueryRequest message, Action<DBQueryResponse> reply)
  9. {
  10. RunAsync(session, message, reply).Coroutine();
  11. }
  12. protected async ETVoid RunAsync(Session session, DBQueryRequest message, Action<DBQueryResponse> reply)
  13. {
  14. DBQueryResponse response = new DBQueryResponse();
  15. try
  16. {
  17. ComponentWithId component = await Game.Scene.GetComponent<DBComponent>().Get(message.CollectionName, message.Id);
  18. response.Component = component;
  19. reply(response);
  20. }
  21. catch (Exception e)
  22. {
  23. ReplyError(response, e, reply);
  24. }
  25. }
  26. }
  27. }