| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482 |
- // (function webpackUniversalModuleDefinition(root, factory) {
- // if(typeof exports === 'object' && typeof module === 'object')
- // module.exports = factory();
- // else if(typeof define === 'function' && define.amd)
- // define([], factory);
- // else if(typeof exports === 'object')
- // exports["qqgame"] = factory();
- // else
- // root["qqgame"] = factory();
- // })(window, function() {
- // return /******/ (function(modules) { // webpackBootstrap
- // /******/ // The module cache
- // /******/ var installedModules = {};
- // /******/
- // /******/ // The require function
- // /******/ function __webpack_require__(moduleId) {
- // /******/
- // /******/ // Check if module is in cache
- // /******/ if(installedModules[moduleId]) {
- // /******/ return installedModules[moduleId].exports;
- // /******/ }
- // /******/ // Create a new module (and put it into the cache)
- // /******/ var module = installedModules[moduleId] = {
- // /******/ i: moduleId,
- // /******/ l: false,
- // /******/ exports: {}
- // /******/ };
- // /******/
- // /******/ // Execute the module function
- // /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- // /******/
- // /******/ // Flag the module as loaded
- // /******/ module.l = true;
- // /******/
- // /******/ // Return the exports of the module
- // /******/ return module.exports;
- // /******/ }
- // /******/
- // /******/
- // /******/ // expose the modules object (__webpack_modules__)
- // /******/ __webpack_require__.m = modules;
- // /******/
- // /******/ // expose the module cache
- // /******/ __webpack_require__.c = installedModules;
- // /******/
- // /******/ // define getter function for harmony exports
- // /******/ __webpack_require__.d = function(exports, name, getter) {
- // /******/ if(!__webpack_require__.o(exports, name)) {
- // /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
- // /******/ }
- // /******/ };
- // /******/
- // /******/ // define __esModule on exports
- // /******/ __webpack_require__.r = function(exports) {
- // /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- // /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- // /******/ }
- // /******/ Object.defineProperty(exports, '__esModule', { value: true });
- // /******/ };
- // /******/
- // /******/ // create a fake namespace object
- // /******/ // mode & 1: value is a module id, require it
- // /******/ // mode & 2: merge all properties of value into the ns
- // /******/ // mode & 4: return value when already ns object
- // /******/ // mode & 8|1: behave like require
- // /******/ __webpack_require__.t = function(value, mode) {
- // /******/ if(mode & 1) value = __webpack_require__(value);
- // /******/ if(mode & 8) return value;
- // /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
- // /******/ var ns = Object.create(null);
- // /******/ __webpack_require__.r(ns);
- // /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
- // /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
- // /******/ return ns;
- // /******/ };
- // /******/
- // /******/ // getDefaultExport function for compatibility with non-harmony modules
- // /******/ __webpack_require__.n = function(module) {
- // /******/ var getter = module && module.__esModule ?
- // /******/ function getDefault() { return module['default']; } :
- // /******/ function getModuleExports() { return module; };
- // /******/ __webpack_require__.d(getter, 'a', getter);
- // /******/ return getter;
- // /******/ };
- // /******/
- // /******/ // Object.prototype.hasOwnProperty.call
- // /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- // /******/
- // /******/ // __webpack_public_path__
- // /******/ __webpack_require__.p = "";
- // /******/
- // /******/
- // /******/ // Load entry module and return exports
- // /******/ return __webpack_require__(__webpack_require__.s = 8);
- // /******/ })
- // /************************************************************************/
- // /******/ ([
- // /* 0 */
- // /***/ (function(module, exports, __webpack_require__) {
- //
- // "use strict";
- //
- //
- // Object.defineProperty(exports, "__esModule", {
- // value: true
- // });
- // var isRobot = getParam('robot') == '1'; // 是否机器人
- // function getParam(name) {
- // var url = location.href;
- // name = name.replace(/[\[\]]/g, "\\$&");
- // var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)");
- // var results = regex.exec(url);
- // if (!results) return null;
- // if (!results[2]) return '';
- // return decodeURIComponent(results[2].replace(/\+/g, " "));
- // }
- //
- // var isIOS = function () {
- // var u = navigator.userAgent.toLowerCase();
- // var flag = u.indexOf('iphone') > -1 || u.indexOf('ipad') > -1;
- // return function () {
- // return flag;
- // };
- // }();
- //
- // var isAndroid = function () {
- // var u = navigator.userAgent.toLowerCase();
- // var flag = u.indexOf('android') > -1;
- // return function () {
- // return flag;
- // };
- // }();
- //
- // var isDebug = location.hostname === 'localhost' || !!getParam('qqdebug');
- //
- // var log = function log(msg) {
- // // console.log('[QQGame SDK]:', msg);
- // };
- //
- // var isQQGame = function isQQGame() {
- // if (isDebug || isRobot) {
- // return true;
- // }
- // return navigator.userAgent.toLowerCase().indexOf('qqgame') != -1;
- // };
- //
- // var userInfo = {};
- // var setUserInfo = function setUserInfo(info) {
- // if (Array.isArray(info)) {
- // info.forEach(function (item) {
- // setUserInfo(item);
- // });
- // } else if (info && info.qqgameid) {
- // // 兼容 gameUin 和 qqgameid
- // var qqgameid = info.qqgameid;
- // userInfo[qqgameid] = info;
- // }
- // };
- //
- // var getUserInfo = function getUserInfo(qqgameid) {
- // if (userInfo[qqgameid]) {
- // return userInfo[qqgameid];
- // }
- // return null;
- // };
- //
- // var getDeviceInfo = function getDeviceInfo() {
- // var devicePixelRatio = window.devicePixelRatio || 1;
- // var devInfo = {
- // statusBarHeight: 20
- // // devicePixelRatio: devicePixelRatio
- // };
- // var ua = navigator.userAgent.toLowerCase();
- // var res = ua.match(/StatusBarHeight\/([\d\.]+)/i);
- // if (Array.isArray(res) && res[1]) {
- // var height = parseInt(res[1]);
- // if (!isNaN(height)) {
- // devInfo.statusBarHeight = parseInt(height / devicePixelRatio);
- // }
- // }
- // return devInfo;
- // };
- //
- // var getEnv = function () {
- // var hallEnv = 'prod';
- // var ua = navigator.userAgent.toLowerCase();
- // var res = ua.match(/\senv\/([\d])\s/i);
- // if (Array.isArray(res) && res[1]) {
- // var env = parseInt(res[1]);
- // if (env == "1") {
- // // 测试
- // hallEnv = 'test';
- // } else if (env == "2") {
- // // 预发布
- // hallEnv = 'prev';
- // } else if (env == "3") {
- // // 正式
- // hallEnv = 'prod';
- // }
- // }
- // return function () {
- // if (isDebug) {
- // return 'test';
- // }
- // return hallEnv;
- // };
- // }();
- //
- // exports.getParam = getParam;
- // exports.isIOS = isIOS;
- // exports.isAndroid = isAndroid;
- // exports.isDebug = isDebug;
- // exports.log = log;
- // exports.isQQGame = isQQGame;
- // exports.getUserInfo = getUserInfo;
- // exports.setUserInfo = setUserInfo;
- // exports.getDeviceInfo = getDeviceInfo;
- // exports.getEnv = getEnv;
- //
- // /***/ }),
- // /* 1 */
- // /***/ (function(module, exports, __webpack_require__) {
- //
- // "use strict";
- //
- //
- // Object.defineProperty(exports, "__esModule", {
- // value: true
- // });
- // exports.disableRobotRender = exports.isRobotRender = exports.robotLevel = exports.isRobot = undefined;
- //
- // var _util = __webpack_require__(0);
- //
- // var isRobot = (0, _util.getParam)('robot') == '1'; // 是否机器人
- // var isRobotRender = (0, _util.getParam)('render') == '1'; // 用于机器人是否渲染
- // var robotLevel;
- //
- // if (isRobot) {
- // exports.robotLevel = robotLevel = (0, _util.getParam)('level');
- // if (robotLevel) {
- // exports.robotLevel = robotLevel = parseInt(robotLevel);
- // exports.robotLevel = robotLevel = isNaN(robotLevel) ? 1 : robotLevel; // 当参数有误时,默认机器人等级为 1
- // }
- // }
- //
- // function disableRobotRender() {
- // if (window.cc) {
- // // cocos robot 屏蔽渲染
- // try {
- // cc.director._visitScene = cc.renderer.clear = cc.renderer.rendering = function () {};
- // } catch (e) {}
- // }
- // }
- //
- // exports.isRobot = isRobot;
- // exports.robotLevel = robotLevel;
- // exports.isRobotRender = isRobotRender;
- // exports.disableRobotRender = disableRobotRender;
- //
- // /***/ }),
- // /* 2 */
- // /***/ (function(module, exports, __webpack_require__) {
- //
- // "use strict";
- //
- //
- // Object.defineProperty(exports, "__esModule", {
- // value: true
- // });
- // exports.default = frameWsInit;
- //
- // var _util = __webpack_require__(0);
- //
- // var _weblog = __webpack_require__(5);
- //
- // var _weblog2 = _interopRequireDefault(_weblog);
- //
- // var _ws = __webpack_require__(4);
- //
- // var _ws2 = _interopRequireDefault(_ws);
- //
- // function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- //
- // var setWebLog = function setWebLog() {};
- // var frameWsIP;
- // var frameWsURL;
- // var frameWs;
- // var uin;
- // var tableKey;
- // var frameSvrId;
- // var frameWs;
- // var frameFps;
- // var frameWsPromise;
- // var frameIndex = -1;
- // var helloTimer;
- // var isWsClosed = false;
- // var cgiPath;
- // var framePort;
- //
- // // 仅用于测试
- // var v1 = '-';
- // var v2 = '-';
- // var v3 = '-';
- //
- // var sendFrameMsg = function sendFrameMsg(msg) {
- // if (isWsClosed) {
- // return;
- // }
- // var header = '{domain=' + frameWsIP + ';cgipath=' + cgiPath + ';cgiquery=uin=' + uin + ';}';
- // try {
- // frameWs.send('' + header.length + header + JSON.stringify(msg));
- // } catch (e) {
- // (0, _util.log)('send frame msg error: ' + JSON.stringify(e));
- // }
- // };
- //
- // var sendFrameReady = function sendFrameReady() {
- // (0, _util.log)('send frame ready');
- // var body = {
- // "Cmd": "frame_ready",
- // "BackString": "frame_ready",
- // "MsgBody": {
- // "session": {
- // "tableKey": tableKey
- // },
- // "fps": frameFps
- // }
- // };
- // sendFrameMsg(body);
- // };
- //
- // var sendFrameHello = function sendFrameHello() {
- // // log(`send frame hello`);
- // var body = {
- // "Cmd": "frame_hello",
- // "BackString": "frame_hello",
- // "MsgBody": {
- // "session": {
- // "tableKey": tableKey
- // },
- // "fps": frameFps
- // }
- // };
- // sendFrameMsg(body);
- // };
- //
- // var sendFrameDataIndex = 0;
- // var sendTimeMap = {};
- // var keyFlag = Math.ceil(Math.random() * 1000000);
- // var sendFrameData = function sendFrameData(data) {
- // if (_util.isDebug) {
- // data.testkey = 'testkey_' + keyFlag + '_' + sendFrameDataIndex++;
- // data.testtime = Date.now();
- // data.testFrameIndex = frameIndex;
- // sendTimeMap[data.testkey] = data.testtime;
- // // log('send frame data');
- // }
- // var body = {
- // "Cmd": "frame_transmit",
- // "BackString": "frame_transmit",
- // "MsgBody": {
- // "session": {
- // "tableKey": tableKey
- // },
- // "frameData": data
- // }
- // };
- // sendFrameMsg(body);
- // };
- //
- // var sendFrameStop = function sendFrameStop() {
- // clearInterval(helloTimer);
- // (0, _util.log)('send frame stop');
- // var body = {
- // "Cmd": "frame_stop",
- // "BackString": "frame_stop",
- // "MsgBody": {
- // "session": {
- // "tableKey": tableKey
- // }
- // }
- // };
- // sendFrameMsg(body);
- // frameWs && frameWs.close && frameWs.close();
- // isWsClosed = true;
- // };
- //
- // var lastFrameMsgTime;
- // var lastHelloMsgTime;
- //
- // function onFrameMessage(frames) {
- // var currentTime = Date.now();
- // if (lastFrameMsgTime) {
- // var cost = currentTime - lastFrameMsgTime; // 两帧时间差
- // frameIndex = frames.frameIndex;
- // //if (cost > 70) {
- // // log(`frameTestGap2, ${cost}, ${frameIndex}`);
- // //}
- // // log(`frameTestGap, ${cost}, ${frameIndex}`);
- // if (frames.frameData) {
- // var testkey = frames.frameData[0].testkey;
- // var testtime = frames.frameData[0].testtime;
- // v1 = frameIndex - frames.frameData[0].testFrameIndex;
- // // log(`frameIndexGap, ${v1}`); // 帧差
- // if (sendTimeMap[testkey]) {
- // v3 = currentTime - testtime;
- // (0, _util.log)('\u81EA\u53D1\u81EA\u6536\u5EF6\u8FDF ' + v3);
- // delete sendTimeMap[testkey];
- // }
- // var text = '\u5E27\u5DEE: ' + v1 + ', \u81EA\u53D1\u81EA\u6536\u5EF6\u8FDF: ' + v3 + ', hello\u5EF6\u8FDF: ' + v2;
- // setWebLog(text);
- // }
- // }
- // lastFrameMsgTime = currentTime;
- // }
- //
- // var frameWsConnect = function frameWsConnect(onMessage) {
- // return new Promise(function (resolve, reject) {
- // frameWs = new _ws2.default(frameWsURL);
- // frameWs.onopen = function () {
- // (0, _util.log)('frame ws open');
- // sendFrameReady();
- // };
- // frameWs.onmessage = function (data) {
- // var msg = data.data;
- // msg = JSON.parse(msg);
- // var cmd = msg.Cmd;
- //
- // if (cmd == 'frame_start') {
- // (0, _util.log)('frame start');
- // resolve();
- // // 发送hello包
- // clearInterval(helloTimer);
- // helloTimer = setInterval(function () {
- // sendFrameHello();
- // lastHelloMsgTime = Date.now();
- // }, 1000);
- // } else if (cmd == 'frame_transmit') {
- // if (msg.MsgBody && msg.MsgBody.frames && msg.MsgBody.frames[0]) {
- // var frames = msg.MsgBody.frames[0];
- // _util.isDebug && onFrameMessage(frames);
- // onMessage(frames);
- // }
- // } else if (cmd == 'frame_hello') {
- // if (_util.isDebug) {
- // v2 = Date.now() - lastHelloMsgTime;
- // (0, _util.log)('frameTestHello ' + v2);
- // var text = '\u5E27\u5DEE: ' + v1 + ', \u81EA\u53D1\u81EA\u6536\u5EF6\u8FDF: ' + v3 + ', hello\u5EF6\u8FDF: ' + v2;
- // setWebLog(text);
- // }
- // }
- // };
- //
- // frameWs.onclose = function () {
- // // isWsClosed = true;
- // (0, _util.log)('frame ws close');
- // };
- //
- // frameWs.onerror = function (error) {
- // (0, _util.log)('frame ws error ' + JSON.stringify(error));
- // };
- // });
- // };
- //
- // function frameWsInit(options) {
- // if (_util.isDebug) {
- // setWebLog = (0, _weblog2.default)();
- // }
- // uin = options.uin;
- // tableKey = options.tableKey;
- // frameSvrId = options.frameSvrId;
- // frameFps = options.frameFps;
- // frameWsIP = options.frameURL;
- // framePort = options.framePort;
- // frameWsURL = frameWsIP + ':' + framePort;
- // cgiPath = options.cgiPath;
- // // console.log(`frameWsURL ${frameWsURL}`)
- // var onMessage = options.onMessage || function () {};
- // var wsPromise = frameWsConnect(onMessage);
- // return {
- // wsPromise: wsPromise,
- // send: sendFrameData,
- // stop: sendFrameStop
- // };
- // }
- //
- // /***/ }),
- // /* 3 */
- // /***/ (function(module, exports, __webpack_require__) {
- //
- // "use strict";
- //
- //
- // Object.defineProperty(exports, "__esModule", {
- // value: true
- // });
- //
- // var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- //
- // exports.default = function (qqgame) {
- // // qqgame.disableRobotRender = disableRobotRender;
- // if (_robot.isRobot) {
- // (0, _robot.disableRobotRender)(); // 正式环境关闭渲染
- // }
- //
- // var invokeClient = function invokeClient(name, params) {
- // var jsonString = JSON.stringify({
- // 'eID': name,
- // 'ePara': params
- // });
- // if (_robot.isRobot) {
- // try {
- // window.pvpRequest(jsonString);
- // } catch (e) {}
- // } else {
- // try {
- // if ((0, _util.isAndroid)()) {
- // if (window.qqgame && window.qqgame.pvpRequest) {
- // window.qqgame.pvpRequest(jsonString);
- // }
- // } else if ((0, _util.isIOS)()) {
- // if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.pvpRequest && window.webkit.messageHandlers.pvpRequest.postMessage) {
- // window.webkit.messageHandlers.pvpRequest.postMessage(jsonString);
- // }
- // }
- // } catch (e) {}
- // }
- // };
- //
- // qqgame.invoke = function (name, params) {
- // // 加防护,游戏结算后,不再接受游戏的invoke
- // if (isGameEnd) {
- // return;
- // }
- //
- // params = params || {};
- // (0, _util.log)('invoke ' + name + ' ' + JSON.stringify(params));
- //
- // if (name == "frameData") {
- // // 用户的操作消息
- // /* if (params && params.data && params.data.id == debugUserId && params.data.msgKey) {
- // var t = Date.now();
- // var msgKey = params.data.msgKey;
- // debugMsgMap[msgKey] = t;
- // } */
- // frameWs.send(params);
- // // qqgame.invoke('frameDataByUDP', params);
- // return;
- // }
- //
- // if (name == 'gameInit' && params.openFraming) {
- // isFrameGame = true;
- // frameFps = params.fpsExpect || 5;
- // params.openFraming = undefined;
- // params.fpsExpect = undefined;
- // }
- //
- // /* if (debugMode) {
- // if (name == 'frameData') {
- // var debugMsgKey = `${debugUserKey}_${Math.ceil(Math.random() * 100000)}`;
- // debugKeyMap[debugMsgKey] = Date.now();
- // params.debugMsgKey = debugMsgKey;
- // }
- // } */
- //
- // // 查看用户信息
- // if (name == "showUser" && (params.gameUin || params.qqgameid)) {
- // var qqgameid = params.gameUin || params.qqgameid;
- // var userInfo = (0, _util.getUserInfo)(qqgameid) || {}; // 可能返回 null
- // params = Object.assign(params, userInfo);
- // }
- //
- // // 加防护,游戏结算后,不再接受游戏的invoke
- // if (name === 'gameResult') {
- // if (params.result && params.result.win == qqgame.RESULT_LEAVE) {
- // // 结算页不处理逃跑,将逃跑转为失败
- // params.result.win = qqgame.RESULT_LOSE;
- // }
- // if (!params.gameType) {
- // params.gameType = "COCOS";
- // }
- // isGameEnd = true;
- //
- // if (isFrameGame) {
- // frameWs.stop();
- // }
- // }
- //
- // invokeClient(name, params);
- // };
- //
- // // 客户端心跳
- // if (!_robot.isRobot) {
- // setInterval(function () {
- // invokeClient('watchDog');
- // }, 3000);
- // }
- //
- // var cbList = [];
- // qqgame.onMessage = function (cb) {
- // cbList.push(cb);
- // };
- //
- // // 客户端调用页面提供的接口
- // qqgame.pvpResponse = function (data) {
- // if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) !== 'object') {
- // data = JSON.parse(data);
- // }
- //
- // var msgType = data.eID;
- // var msgData = data.ePara;
- //
- // if (msgType === 'gameReset') {
- // isGameEnd = false;
- // // isChannelCreated = false;
- // }
- //
- // // 加防护,游戏结算后,不再接受客户端的消息
- // if (isGameEnd) {
- // return;
- // }
- //
- // if (msgType !== 'frameData') {
- // (0, _util.log)('onMessage ' + JSON.stringify(data));
- // }
- //
- // if (msgType == 'frameData') {
- // if (Array.isArray(msgData.frames)) {
- // msgData = msgData.frames[0];
- // }
- // }
- //
- // // 保存用户信息
- // if (msgType == 'channelCreated') {
- // var playerInfos = msgData.playerInfos;
- // (0, _util.setUserInfo)(playerInfos);
- // }
- //
- // if (msgType == "channelCreating") {
- // if (isFrameGame) {
- // tableKey = msgData.tableKey;
- // cgiPath = msgData.url.transmitSvr.cgipath;
- // frameURL = msgData.url.transmitSvr.domain;
- // framePort = msgData.url.transmitSvr.port;
- // }
- // return;
- // }
- //
- // // 如果是帧同步,拦截channelCreated,等直连成功后,再通知游戏channelCreated
- // if (msgType == "channelCreated") {
- // if (isFrameGame) {
- // uin = msgData.playerInfos[0].qqgameid;
- // // debugUserId = 1000 + msgData.playerInfos[0].seat;
- // frameWs = (0, _frame2.default)({
- // uin: uin,
- // frameFps: frameFps,
- // tableKey: tableKey,
- // cgiPath: cgiPath,
- // frameURL: frameURL,
- // framePort: framePort,
- // onMessage: function onMessage(data) {
- // pvpResponse('frameData', data);
- // /* qqgame.pvpResponse({
- // eID: 'frameData',
- // ePara: data
- // }); */
- // }
- // });
- // frameWs.wsPromise.then(function () {
- // // isChannelCreated = true;
- // // qqgame.pvpResponse(data);
- // pvpResponse(msgType, msgData);
- // });
- // return;
- // }
- // }
- //
- // /* if (msgType == 'frameData') {
- // if (Array.isArray(msgData.frames)) {
- // msgData = msgData.frames[0];
- // if (debugMode) {
- // var data = msgData;
- // var index = data.frameIndex;
- // if (Array.isArray(data.frameData)) {
- // data.frameData.forEach((frameItem) => {
- // var msgKey = frameItem.debugMsgKey;
- // if (debugKeyMap[msgKey]) {
- // var sendTime = debugKeyMap[msgKey];
- // var t = Date.now();
- // log(`自发自收延迟: ${t - sendTime}`)
- // delete debugKeyMap[msgKey];
- // }
- // });
- // }
- // }
- // } else {
- // return;
- // }
- // }*/
- //
- // pvpResponse(msgType, msgData);
- // };
- //
- // qqgame.setDebugAppid = function () {};
- //
- // var pvpResponse = function pvpResponse(msgType, msgData) {
- // cbList.forEach(function (cb) {
- // cb(msgType, msgData);
- // });
- // };
- // };
- //
- // var _util = __webpack_require__(0);
- //
- // var _robot = __webpack_require__(1);
- //
- // var _frame = __webpack_require__(2);
- //
- // var _frame2 = _interopRequireDefault(_frame);
- //
- // function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- //
- // var debugMode = false;
- // // var debugUserId;
- // // var debugMsgMap = {};
- // // 都是帧同步相关
- // var isFrameGame = false;
- // var frameFps = 5;
- // var frameWs;
- // var uin;
- // var frameURL;
- // var framePort;
- // var cgiPath;
- // var tableKey;
- // var frameSvrId;
- //
- // var isGameEnd = false;
- // // var debugKeyMap = {}; // 調試使用
- // // var debugUserKey = Math.ceil(Math.random() * 100000); // 調試使用
- //
- // /***/ }),
- // /* 4 */
- // /***/ (function(module, exports, __webpack_require__) {
- //
- // "use strict";
- // var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
- //
- // // MIT License:
- // //
- // // Copyright (c) 2010-2012, Joe Walnes
- // //
- // // Permission is hereby granted, free of charge, to any person obtaining a copy
- // // of this software and associated documentation files (the "Software"), to deal
- // // in the Software without restriction, including without limitation the rights
- // // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- // // copies of the Software, and to permit persons to whom the Software is
- // // furnished to do so, subject to the following conditions:
- // //
- // // The above copyright notice and this permission notice shall be included in
- // // all copies or substantial portions of the Software.
- // //
- // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- // // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- // // THE SOFTWARE.
- //
- // /**
- // * This behaves like a WebSocket in every way, except if it fails to connect,
- // * or it gets disconnected, it will repeatedly poll until it successfully connects
- // * again.
- // *
- // * It is API compatible, so when you have:
- // * ws = new WebSocket('ws://....');
- // * you can replace with:
- // * ws = new ReconnectingWebSocket('ws://....');
- // *
- // * The event stream will typically look like:
- // * onconnecting
- // * onopen
- // * onmessage
- // * onmessage
- // * onclose // lost connection
- // * onconnecting
- // * onopen // sometime later...
- // * onmessage
- // * onmessage
- // * etc...
- // *
- // * It is API compatible with the standard WebSocket API, apart from the following members:
- // *
- // * - `bufferedAmount`
- // * - `extensions`
- // * - `binaryType`
- // *
- // * Latest version: https://github.com/joewalnes/reconnecting-websocket/
- // * - Joe Walnes
- // *
- // * Syntax
- // * ======
- // * var socket = new ReconnectingWebSocket(url, protocols, options);
- // *
- // * Parameters
- // * ==========
- // * url - The url you are connecting to.
- // * protocols - Optional string or array of protocols.
- // * options - See below
- // *
- // * Options
- // * =======
- // * Options can either be passed upon instantiation or set after instantiation:
- // *
- // * var socket = new ReconnectingWebSocket(url, null, { debug: true, reconnectInterval: 4000 });
- // *
- // * or
- // *
- // * var socket = new ReconnectingWebSocket(url);
- // * socket.debug = true;
- // * socket.reconnectInterval = 4000;
- // *
- // * debug
- // * - Whether this instance should log debug messages. Accepts true or false. Default: false.
- // *
- // * automaticOpen
- // * - Whether or not the websocket should attempt to connect immediately upon instantiation. The socket can be manually opened or closed at any time using ws.open() and ws.close().
- // *
- // * reconnectInterval
- // * - The number of milliseconds to delay before attempting to reconnect. Accepts integer. Default: 1000.
- // *
- // * maxReconnectInterval
- // * - The maximum number of milliseconds to delay a reconnection attempt. Accepts integer. Default: 30000.
- // *
- // * reconnectDecay
- // * - The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. Accepts integer or float. Default: 1.5.
- // *
- // * timeoutInterval
- // * - The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. Accepts integer. Default: 2000.
- // *
- // */
- // (function (global, factory) {
- // if (true) {
- // !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
- // __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
- // (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
- // __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- // } else {}
- // })(undefined, function () {
- //
- // if (!('WebSocket' in window)) {
- // return;
- // }
- //
- // function ReconnectingWebSocket(url, protocols, options) {
- //
- // // Default settings
- // var settings = {
- //
- // /** Whether this instance should log debug messages. */
- // debug: false,
- //
- // /** Whether or not the websocket should attempt to connect immediately upon instantiation. */
- // automaticOpen: true,
- //
- // /** The number of milliseconds to delay before attempting to reconnect. */
- // reconnectInterval: 1000,
- // /** The maximum number of milliseconds to delay a reconnection attempt. */
- // maxReconnectInterval: 30000,
- // /** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */
- // reconnectDecay: 1.5,
- //
- // /** The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. */
- // timeoutInterval: 2000,
- //
- // /** The maximum number of reconnection attempts to make. Unlimited if null. */
- // maxReconnectAttempts: 100, // null,
- //
- // /** The binary type, possible values 'blob' or 'arraybuffer', default 'blob'. */
- // binaryType: 'blob'
- // };
- // if (!options) {
- // options = {};
- // }
- //
- // // Overwrite and define settings with options if they exist.
- // for (var key in settings) {
- // if (typeof options[key] !== 'undefined') {
- // this[key] = options[key];
- // } else {
- // this[key] = settings[key];
- // }
- // }
- //
- // // These should be treated as read-only properties
- //
- // /** The URL as resolved by the constructor. This is always an absolute URL. Read only. */
- // this.url = url;
- //
- // /** The number of attempted reconnects since starting, or the last successful connection. Read only. */
- // this.reconnectAttempts = 0;
- //
- // /**
- // * The current state of the connection.
- // * Can be one of: WebSocket.CONNECTING, WebSocket.OPEN, WebSocket.CLOSING, WebSocket.CLOSED
- // * Read only.
- // */
- // this.readyState = WebSocket.CONNECTING;
- //
- // /**
- // * A string indicating the name of the sub-protocol the server selected; this will be one of
- // * the strings specified in the protocols parameter when creating the WebSocket object.
- // * Read only.
- // */
- // this.protocol = null;
- //
- // // Private state variables
- //
- // var self = this;
- // var ws;
- // var forcedClose = false;
- // var timedOut = false;
- // var eventTarget = document.createElement('div');
- //
- // // Wire up "on*" properties as event handlers
- //
- // eventTarget.addEventListener('open', function (event) {
- // self.onopen(event);
- // });
- // eventTarget.addEventListener('close', function (event) {
- // self.onclose(event);
- // });
- // eventTarget.addEventListener('connecting', function (event) {
- // self.onconnecting(event);
- // });
- // eventTarget.addEventListener('message', function (event) {
- // self.onmessage(event);
- // });
- // eventTarget.addEventListener('error', function (event) {
- // self.onerror(event);
- // });
- //
- // // Expose the API required by EventTarget
- //
- // this.addEventListener = eventTarget.addEventListener.bind(eventTarget);
- // this.removeEventListener = eventTarget.removeEventListener.bind(eventTarget);
- // this.dispatchEvent = eventTarget.dispatchEvent.bind(eventTarget);
- //
- // /**
- // * This function generates an event that is compatible with standard
- // * compliant browsers and IE9 - IE11
- // *
- // * This will prevent the error:
- // * Object doesn't support this action
- // *
- // * http://stackoverflow.com/questions/19345392/why-arent-my-parameters-getting-passed-through-to-a-dispatched-event/19345563#19345563
- // * @param s String The name that the event should use
- // * @param args Object an optional object that the event will use
- // */
- // function generateEvent(s, args) {
- // var evt = document.createEvent("CustomEvent");
- // evt.initCustomEvent(s, false, false, args);
- // return evt;
- // };
- //
- // this.open = function (reconnectAttempt) {
- // ws = new WebSocket(self.url, protocols || []);
- // ws.binaryType = this.binaryType;
- //
- // if (reconnectAttempt) {
- // if (this.maxReconnectAttempts && this.reconnectAttempts > this.maxReconnectAttempts) {
- // return;
- // }
- // } else {
- // eventTarget.dispatchEvent(generateEvent('connecting'));
- // this.reconnectAttempts = 0;
- // }
- //
- // if (self.debug || ReconnectingWebSocket.debugAll) {
- // console.debug('ReconnectingWebSocket', 'attempt-connect', self.url);
- // }
- //
- // var localWs = ws;
- // var timeout = setTimeout(function () {
- // if (self.debug || ReconnectingWebSocket.debugAll) {
- // console.debug('ReconnectingWebSocket', 'connection-timeout', self.url);
- // }
- // timedOut = true;
- // localWs.close();
- // timedOut = false;
- // }, self.timeoutInterval);
- //
- // ws.onopen = function (event) {
- // clearTimeout(timeout);
- // if (self.debug || ReconnectingWebSocket.debugAll) {
- // console.debug('ReconnectingWebSocket', 'onopen', self.url);
- // }
- // self.protocol = ws.protocol;
- // self.readyState = WebSocket.OPEN;
- // self.reconnectAttempts = 0;
- // var e = generateEvent('open');
- // e.isReconnect = reconnectAttempt;
- // reconnectAttempt = false;
- // eventTarget.dispatchEvent(e);
- // };
- //
- // ws.onclose = function (event) {
- // clearTimeout(timeout);
- // ws = null;
- // if (forcedClose) {
- // self.readyState = WebSocket.CLOSED;
- // eventTarget.dispatchEvent(generateEvent('close'));
- // } else {
- // self.readyState = WebSocket.CONNECTING;
- // var e = generateEvent('connecting');
- // e.code = event.code;
- // e.reason = event.reason;
- // e.wasClean = event.wasClean;
- // eventTarget.dispatchEvent(e);
- // if (!reconnectAttempt && !timedOut) {
- // if (self.debug || ReconnectingWebSocket.debugAll) {
- // console.debug('ReconnectingWebSocket', 'onclose', self.url);
- // }
- // eventTarget.dispatchEvent(generateEvent('close'));
- // }
- //
- // var timeout = self.reconnectInterval * Math.pow(self.reconnectDecay, self.reconnectAttempts);
- // setTimeout(function () {
- // self.reconnectAttempts++;
- // self.open(true);
- // }, timeout > self.maxReconnectInterval ? self.maxReconnectInterval : timeout);
- // }
- // };
- // ws.onmessage = function (event) {
- // if (self.debug || ReconnectingWebSocket.debugAll) {
- // console.debug('ReconnectingWebSocket', 'onmessage', self.url, event.data);
- // }
- // var e = generateEvent('message');
- // e.data = event.data;
- // eventTarget.dispatchEvent(e);
- // };
- // ws.onerror = function (event) {
- // if (self.debug || ReconnectingWebSocket.debugAll) {
- // console.debug('ReconnectingWebSocket', 'onerror', self.url, event);
- // }
- // eventTarget.dispatchEvent(generateEvent('error'));
- // };
- // };
- //
- // // Whether or not to create a websocket upon instantiation
- // if (this.automaticOpen == true) {
- // this.open(false);
- // }
- //
- // /**
- // * Transmits data to the server over the WebSocket connection.
- // *
- // * @param data a text string, ArrayBuffer or Blob to send to the server.
- // */
- // this.send = function (data) {
- // if (ws) {
- // if (self.debug || ReconnectingWebSocket.debugAll) {
- // console.debug('ReconnectingWebSocket', 'send', self.url, data);
- // }
- // return ws.send(data);
- // } else {
- // throw 'INVALID_STATE_ERR : Pausing to reconnect websocket';
- // }
- // };
- //
- // /**
- // * Closes the WebSocket connection or connection attempt, if any.
- // * If the connection is already CLOSED, this method does nothing.
- // */
- // this.close = function (code, reason) {
- // // Default CLOSE_NORMAL code
- // if (typeof code == 'undefined') {
- // code = 1000;
- // }
- // forcedClose = true;
- // if (ws) {
- // ws.close(code, reason);
- // }
- // };
- //
- // /**
- // * Additional public API method to refresh the connection if still open (close, re-open).
- // * For example, if the app suspects bad data / missed heart beats, it can try to refresh.
- // */
- // this.refresh = function () {
- // if (ws) {
- // ws.close();
- // }
- // };
- // }
- //
- // /**
- // * An event listener to be called when the WebSocket connection's readyState changes to OPEN;
- // * this indicates that the connection is ready to send and receive data.
- // */
- // ReconnectingWebSocket.prototype.onopen = function (event) {};
- // /** An event listener to be called when the WebSocket connection's readyState changes to CLOSED. */
- // ReconnectingWebSocket.prototype.onclose = function (event) {};
- // /** An event listener to be called when a connection begins being attempted. */
- // ReconnectingWebSocket.prototype.onconnecting = function (event) {};
- // /** An event listener to be called when a message is received from the server. */
- // ReconnectingWebSocket.prototype.onmessage = function (event) {};
- // /** An event listener to be called when an error occurs. */
- // ReconnectingWebSocket.prototype.onerror = function (event) {};
- //
- // /**
- // * Whether all instances of ReconnectingWebSocket should log debug messages.
- // * Setting this to true is the equivalent of setting all instances of ReconnectingWebSocket.debug to true.
- // */
- // ReconnectingWebSocket.debugAll = false;
- //
- // ReconnectingWebSocket.CONNECTING = WebSocket.CONNECTING;
- // ReconnectingWebSocket.OPEN = WebSocket.OPEN;
- // ReconnectingWebSocket.CLOSING = WebSocket.CLOSING;
- // ReconnectingWebSocket.CLOSED = WebSocket.CLOSED;
- //
- // return ReconnectingWebSocket;
- // });
- //
- // /***/ }),
- // /* 5 */
- // /***/ (function(module, exports, __webpack_require__) {
- //
- // "use strict";
- //
- //
- // Object.defineProperty(exports, "__esModule", {
- // value: true
- // });
- // exports.default = debugInit;
- // function debugInit() {
- // var container = document.createElement('div');
- // container.style.display = 'none';
- // var isVisible = false; // 刚开始不可见,调用setFrameDebugText后,才可见
- // // var isFrameDebugClosed = false;
- // // var isEnabled = false;
- // var style = {
- // 'position': 'absolute',
- // 'top': 0,
- // 'left': 0,
- // 'height': '20px',
- // 'line-height': '20px',
- // 'z-index': 10000,
- // 'width': '100%',
- // 'padding': '5px 10px',
- // 'color': '#F76a24',
- // 'background-color': '#fefcec',
- // 'font-family': '\'Helvetica Neue\', \'Hiragino Sans GB\', Helvetica'
- // };
- // var styleString = '';
- // for (var k in style) {
- // var v = style[k];
- // styleString += k + ': ' + v + ';';
- // }
- //
- // var closeBtnStyle = {
- // 'position': 'absolute',
- // 'right': 0,
- // 'top': 0,
- // 'padding': '5px 10px',
- // 'z-index': 10001
- // };
- // var closeStyleString = '';
- // for (var k in closeBtnStyle) {
- // var v = closeBtnStyle[k];
- // closeStyleString += k + ': ' + v + ';';
- // }
- //
- // container.innerHTML = '<div style="' + styleString + '" id="framedebug"></div><span id="framedebugclose" style="' + closeStyleString + '">\xD7</span>';
- //
- // // sdk加载在head中,当sdk执行时,可能获取不到body,需要onload之后,才将执行append
- // // window.addEventListener('load', function () {
- // document.body.appendChild(container);
- // var div = document.querySelector('#framedebug');
- // var isEnabled = true;
- // document.querySelector("#framedebugclose").onclick = function () {
- // isEnabled = false;
- // container.style.display = 'none';
- // };
- // // });
- //
- // function setDebugText(text) {
- // if (!isEnabled) {
- // return;
- // }
- // if (!isVisible) {
- // // 最开始不可见,第一次调用后,才可见
- // container.style.display = 'block ';
- // isVisible = true;
- // }
- // div.innerText = text;
- // }
- // return setDebugText;
- // }
- //
- // /***/ }),
- // /* 6 */
- // /***/ (function(module, exports, __webpack_require__) {
- //
- // "use strict";
- //
- //
- // Object.defineProperty(exports, "__esModule", {
- // value: true
- // });
- // exports.setDebugAppid = exports.getQQ = exports.getAppid = undefined;
- //
- // var _util = __webpack_require__(0);
- //
- // var debugAppid;
- // var debugAppidList = [8000343, 8000369, 8000370, 8000371, 8000372, 8000379, 8000381, 8000382, 8000383, 8000384, 8000385, 8000386, 8000387, 8000486, 8000489, 8000497, 8000498, 8000499, 8000500, 8000510, 8000513, 8000514, 8000515];
- //
- // function isAppidVaild(appid) {
- // appid = parseInt(appid);
- // if (debugAppidList.indexOf(appid) > -1) {
- // return true;
- // }
- // return false;
- // }
- //
- // // 生成随机QQ,不再支持指定QQ
- // function getQQ() {
- // var qq = Math.ceil(Math.random() * 1000000000 + 10000);
- // (0, _util.log)('qq ' + qq);
- // return qq;
- // }
- //
- // function setDebugAppid(appid) {
- // debugAppid = appid;
- // }
- //
- // function getAppid() {
- // if (debugAppid) {
- // return debugAppid;
- // }
- // var appid = (0, _util.getParam)('appid');
- // if (isAppidVaild(appid)) {
- // return appid;
- // }
- // return debugAppidList[0];
- // }
- //
- // exports.getAppid = getAppid;
- // exports.getQQ = getQQ;
- // exports.setDebugAppid = setDebugAppid;
- //
- // /***/ }),
- // /* 7 */
- // /***/ (function(module, exports, __webpack_require__) {
- //
- // "use strict";
- //
- //
- // Object.defineProperty(exports, "__esModule", {
- // value: true
- // });
- //
- // var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- //
- // exports.default = function (qqgame) {
- // var frameWs;
- // var uin;
- // var isFrameGame;
- // var frameFps;
- // var isGameEnd = false;
- // // var helloMsgTimer = null;
- // var ws;
- //
- // qqgame.setDebugAppid = _util2.setDebugAppid;
- // qqgame.invoke = function (name, params) {
- // if (isGameEnd) {
- // return;
- // }
- // params = params || {};
- // (0, _util.log)('invoke ' + name + ' ' + JSON.stringify(params));
- //
- // if (name == "frameData") {
- // frameWs.send(params);
- // return;
- // }
- //
- // wsPromise.then(function () {
- // var json = {
- // 'eID': name,
- // 'ePara': params
- // };
- //
- // if (name == 'gameInit') {
- // params.appid = (0, _util2.getAppid)();
- // (0, _util.log)('appid ' + params.appid);
- // params.qq = uin = (0, _util2.getQQ)();
- // // 帧同步直连
- // if (params.openFraming) {
- // isFrameGame = true;
- // frameFps = params.fpsExpect;
- // params.openFraming = undefined;
- // params.fpsExpect = undefined;
- // }
- // }
- //
- // // 如果游戏结束,长连接不再发心跳
- // // gameExit 只有debug环境下才有这个eID
- // if (name == 'gameResult' || name == 'gameExit') {
- // isGameEnd = true;
- // // clearInterval(helloMsgTimer);
- // isFrameGame && frameWs.stop();
- // }
- // ws.send(JSON.stringify(json));
- // });
- // };
- //
- // var cbList = [];
- // qqgame.onMessage = function (cb) {
- // cbList.push(cb);
- // };
- //
- // // 客户端调用页面提供的接口
- // qqgame.pvpResponse = function (data) {
- // // if (name === 'gameReset') {
- // // isGameEnd = false;
- // // }
- //
- // // 加防护,游戏结算后,不再接受客户端的消息
- // if (isGameEnd) {
- // return;
- // }
- //
- // if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) !== 'object') {
- // data = JSON.parse(data);
- // }
- // var msgType = data.eID;
- // var msgData = data.ePara;
- // if (msgType !== 'frameData') {
- // (0, _util.log)('onMessage ' + JSON.stringify(data));
- // }
- //
- // cbList.forEach(function (cb) {
- // cb(msgType, msgData);
- // });
- // };
- //
- // var wsPromise = function () {
- // return new Promise(function (resolve, reject) {
- // var wsURL = 'ws://test.go.minigame.qq.com/h5pvpservice/';
- // ws = new WebSocket(wsURL);
- // ws.onopen = function () {
- // resolve();
- // (0, _util.log)('ws open');
- // };
- //
- // ws.onmessage = function (data) {
- // var msg = data.data;
- // msg = JSON.parse(msg);
- // var cmd = msg.eID;
- //
- // if (isFrameGame) {
- // if (cmd == "session") {
- // var tableKey = msg.ePara.tableKey;
- // var frameSvrId = msg.ePara.frameSvrId;
- // frameWs = (0, _frame2.default)({
- // uin: uin,
- // tableKey: tableKey,
- // frameSvrId: frameSvrId,
- // frameFps: frameFps,
- // frameURL: 'ws://test.trans.mobile.minigame.qq.com',
- // framePort: 9050,
- // cgiPath: '',
- // onMessage: function onMessage(data) {
- // qqgame.pvpResponse({
- // eID: 'frameData',
- // ePara: data
- // });
- // }
- // });
- // return;
- // }
- //
- // // 如果是帧同步,拦截channelCreated,等直连成功后,再通知游戏channelCreated
- // if (cmd == "channelCreated") {
- // frameWs.wsPromise.then(function () {
- // qqgame.pvpResponse(msg);
- // });
- // return;
- // }
- // }
- //
- // if (cmd == "leave") {
- // isGameEnd = true;
- // // clearInterval(helloMsgTimer);
- // isFrameGame && frameWs.stop();
- // }
- // qqgame.pvpResponse(msg);
- // };
- //
- // ws.onerror = function (error) {
- // (0, _util.log)('ws error ' + JSON.stringify(error));
- // };
- // });
- // }();
- //
- // window.addEventListener('beforeunload', function () {
- // if (!isGameEnd) {
- // // 如果已经发送过gameResult,这里则不再发送
- // qqgame.invoke('gameExit');
- // }
- // });
- // };
- //
- // var _util = __webpack_require__(0);
- //
- // var _util2 = __webpack_require__(6);
- //
- // var _frame = __webpack_require__(2);
- //
- // var _frame2 = _interopRequireDefault(_frame);
- //
- // function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- //
- // /***/ }),
- // /* 8 */
- // /***/ (function(module, exports, __webpack_require__) {
- //
- // "use strict";
- //
- //
- // var _util = __webpack_require__(0);
- //
- // var _sdk = __webpack_require__(7);
- //
- // var _sdk2 = _interopRequireDefault(_sdk);
- //
- // var _sdk3 = __webpack_require__(3);
- //
- // var _sdk4 = _interopRequireDefault(_sdk3);
- //
- // var _robot = __webpack_require__(1);
- //
- // function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- //
- // var qqgame = window.qqgame = window.qqgame || {};
- //
- // // 避免多次加载 SDK
- // if (!qqgame.invoke) {
- // qqgame.version = '0.3.5-beta.1';
- // // Web SDK 是否已重载机器人相关函数
- // qqgame.isWebSDKOverloadRobotFunction = true;
- // (0, _util.log)('version ' + qqgame.version);
- // (0, _util.log)('WiKi https://qqgame.qq.com/h5wiki/pvp-sdk');
- //
- // qqgame.isQQGame = _util.isQQGame;
- // qqgame.getDeviceInfo = _util.getDeviceInfo;
- // qqgame.isAndroid = _util.isAndroid;
- // qqgame.isIOS = _util.isIOS;
- // qqgame.getEnv = _util.getEnv;
- //
- // qqgame.isRobot = _robot.isRobot;
- // qqgame.robotLevel = _robot.robotLevel;
- //
- // qqgame.RESULT_LOSE = -1; // 失败
- // qqgame.RESULT_DRAW = 0; //平局
- // qqgame.RESULT_WIN = 1; // 胜利
- // qqgame.RESULT_LEAVE = 2; // 逃跑
- // qqgame.RESULT_TYPE_RESULT = 1; // 胜负结算
- // qqgame.RESULT_TYPE_RANK = 2; // 排名结算
- //
- // if (_util.isDebug) {
- // (0, _sdk2.default)(qqgame);
- // } else {
- // (0, _sdk4.default)(qqgame);
- // }
- // }
- //
- // module.exports = qqgame;
- //
- // /***/ })
- // /******/ ]);
- // });
|