SocketPlayer.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { _decorator } from 'cc';
  2. import { JCMGO } from '../ThirdParty/JCMGO';
  3. import { BuiltinMatchInfos } from './View/GameMatchView';
  4. export class SocketPlayer extends JCMGO.SocketClient {
  5. constructor() {
  6. super()
  7. this.connect("wss://www.9527fun.cn/JCMiniGameOnline?gameId=跑步Demo2");
  8. }
  9. protected onLoad(): void {
  10. this.singlePersonRandomMatching({
  11. playerInfo: BuiltinMatchInfos.myPlayerInfo,
  12. matchRoomConfig: {
  13. type: window.gm.config.roomMatchType,
  14. syncFrameRate: window.gm.config.syncFrameRate,
  15. maxMatchingTime: window.gm.config.debugQuicklyStartGame ? 0 : window.gm.config.maxMatchingTime,
  16. maxMembers: window.gm.config.maxMembers,
  17. }
  18. });
  19. }
  20. protected onReload(): void {
  21. }
  22. protected onDestroy(): void {
  23. }
  24. protected onMiss(): void {
  25. }
  26. protected onRoomAddPlayer(e: JCMGO.BroadcastEvent<JCMGO.RoomAddPlayerBst>): void {
  27. window.gm.mode.handleEnterRoom(e.data);
  28. }
  29. protected onRoomRemovePlayer(e: JCMGO.BroadcastEvent<JCMGO.RoomRemovePlayerBst>): void {
  30. }
  31. protected onRoomEndMatching(e: JCMGO.BroadcastEvent<JCMGO.RoomEndMatchingBst>): void {
  32. window.gm.mode.handleMatchComplete(e.data);
  33. }
  34. protected onFrameSyncStart(e: JCMGO.BroadcastEvent<null>): void {
  35. window.gm.mode.handleFrameSyncStart();
  36. }
  37. protected onRecvFrame(e: JCMGO.BroadcastEvent<JCMGO.Frame>): void {
  38. window.gm.mode.handleRecvFrame(e.data);
  39. }
  40. }