CommonClient.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * ioGame
  3. * Copyright (C) 2021 - 2023 渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
  4. * # iohao.com . 渔民小镇
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. package com.iohao.mmo.client;
  20. import com.iohao.game.external.client.InputCommandRegion;
  21. import com.iohao.game.external.client.join.ClientRunOne;
  22. import com.iohao.game.external.client.user.ClientUser;
  23. import com.iohao.game.external.client.user.DefaultClientUser;
  24. import com.iohao.mmo.login.client.LoginInputCommandRegion;
  25. import java.util.List;
  26. /**
  27. * @author 渔民小镇
  28. * @date 2023-07-21
  29. */
  30. public class CommonClient {
  31. private static List<InputCommandRegion> listInputCommandRegion() {
  32. LoginInputCommandRegion loginInputCommandRegion = new LoginInputCommandRegion();
  33. // 模拟请求数据
  34. return List.of(
  35. // 登录
  36. loginInputCommandRegion
  37. );
  38. }
  39. static void start(long userId) {
  40. // 客户端的用户(玩家)
  41. ClientUser clientUser = new DefaultClientUser();
  42. clientUser.setJwt(String.valueOf(userId));
  43. List<InputCommandRegion> inputCommandRegions = listInputCommandRegion();
  44. // 启动模拟客户端
  45. new ClientRunOne()
  46. .setClientUser(clientUser)
  47. .setInputCommandRegions(inputCommandRegions)
  48. .startup();
  49. }
  50. }