DBQueryJsonRequestHandler.cs 913 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections.Generic;
  3. using ETModel;
  4. namespace ETHotfix
  5. {
  6. [MessageHandler(AppType.DB)]
  7. public class DBQueryJsonRequestHandler : AMRpcHandler<DBQueryJsonRequest, DBQueryJsonResponse>
  8. {
  9. protected override void Run(Session session, DBQueryJsonRequest message, Action<DBQueryJsonResponse> reply)
  10. {
  11. RunAsync(session, message, reply).NoAwait();
  12. }
  13. protected async ETVoid RunAsync(Session session, DBQueryJsonRequest message, Action<DBQueryJsonResponse> reply)
  14. {
  15. DBQueryJsonResponse response = new DBQueryJsonResponse();
  16. try
  17. {
  18. DBCacheComponent dbCacheComponent = Game.Scene.GetComponent<DBCacheComponent>();
  19. List<ComponentWithId> components = await dbCacheComponent.GetJson(message.CollectionName, message.Json);
  20. response.Components = components;
  21. reply(response);
  22. }
  23. catch (Exception e)
  24. {
  25. ReplyError(response, e, reply);
  26. }
  27. }
  28. }
  29. }