COCOS-JS network communication reads and writes messages and load proto files

/** * Created by Lovell on 16/6/20.  *//** * html decode * @param < span style="color:#629755;font-style:italic;">str * @returns {string}  */pg.htmlDecodeByRegExp = function (str) {var < /span>s = ""; if (str.length = = 0) return ""; s = str.replace(/&/g, < /span>"&"); s = s.replace(/</g< span style="color:#cc7832;">, "<"); s = s.replace< /span>(/>/g, ">"); s = s.< span style="color:#ffc66d;">replace(/ /g , " "); s = s.replace(/'/g, "\' "); s = s.replace(/"""/g, "\"< /span>"); return s;};/**  * safe retain * @param  obj * @constructor */pg.SAFERETAIN = function (obj) {if (obj && obj.retain) {obj.retain(); }};/**< /span> * safe release * @param obj  * @constructor */pg.SAFERELEASE = function < /span>(obj) {if (obj && obj.release) {obj.release(); }};/** * load proto file, return contents * @param  path * @param str< s pan style="color:#629755;font-style:italic;"> * @returns  span>{!ProtoBuf.Builder.Message|!Object.} */pg.loadProto = function (path, str) {if < /span>(typeof dcodeIO === 'undefined' || !dcodeIO.ProtoBuf ) {throw (new < /span>Error("ProtoBuf.js is not present. Plese see Please see www/index.html for manu al setup instructions."))} var ProtoBuf = dcodeIO .ProtoBuf; var Contents = ProtoBuf.loadProtoFile( path).build(str); return Contents? Contents: null;};/** * create proto * @param path * @param str * @returns {*} */pg.createProto = function (path, str) {var Proto = new pg.loadProto(path, str); var data = new  Proto(); return data? data: null;< /span>};/** * read msg * @param msg * @returns {Uint8Array} */pg.readMsg =  function (msg) {if (!msg) {return null; } var binary = new Uint8Array(msg); var < /span>message = new Uint8Array(binary.byteLength-4); for (var i = 0< /span>; i 4; i++) {message[i] = binary[4 + i]; } return message;};< span style="color:#629755;font-style:italic;">/** * write msg< span style="color:#629755;font-style:italic;"> * @param type * @param msg * @returns {Uint8Array} */pg.< span style="color:#ffc66d;">writeMsg = function (type, msg) {if (!type || !msg) {return null; } var binary = msg.toArrayBuffer(); var byteLength = binary.byteLength + 4 ; msg = new ArrayBuffer(4 + byteLength); var view = new Uint8Array(msg); var len = 2; var tmp = new Uint8Array(len); for ( var i = 0; i ; i++) {tmp[i] = 0xff & (byteLength >> (8 * (len-i-1))); view[i] = tmp[i]; < /span>} tmp = new Uint8Array(len);  for (var i = 0; i ; i++) {tmp[i] = 0xff & (type >> ( 8 * (len-i-1))); view[i + 2] = tmp[i]; } tmp = new Uint8Array(binary); for (var i = 0; i ; i++) {view[i + 4] = tmp[i]; } return msg;}; /** * get msg type * @param < span style="color:#629755;font-style:italic;">msg * @returns {number}  */pg.getMsgType = function (msg) {if (!msg) {< span style="color:#cc7832;font-weight:bold;">return 0; } var binary = < span style="color:#cc7832;font-weight:bold;">new Uint8Array(msg); var type = 0; for (var i = 0 ; i <2; < /span>i++) {type |= binary[i + 2] << (8 * (2 - i-1)); } return type ;};

/** * Created by Lovell on 16/6/20. *//** * html decode * @param str * @returns {string} */pg.htmlDecodeByRegE xp = function (str) {var s = ""; if (str.length == 0) return ""; s = str. replace(/&/g, "&"); s = s.replace(/</g, "<"); s = s.replace(/>/g, ">"); s = s.replace(/ /g, " "); s = s.replace(/' /g, "\'"); s = s.replace(/""" / g, "\""); return s;} ;/** * safe retain * @param obj * @constructor */pg.SAFERETAIN = function (obj) {if (obj && obj.retain) {obj.retain(); }};/* * * safe release * < /span>@param obj * @constructor */pg.SAFERELEASE = function (obj) {if (obj && obj. release) {obj.release(); }};/** * load proto file, return contents  * @param < /span>path * < span style="color:#629755;font-weight:bold;font-style:italic;">@param str * @ returns {!ProtoBuf.Builder.Message|!Object.} */pg.loadProto = function (path, str) {if (typeof dcodeIO === 'undefined' || !dcodeIO.ProtoBuf) {throw (new Error("ProtoBuf.js is not present. Plese see Please see www/index.html f or manual setup instructions."))} var ProtoBuf =  dcodeIO.ProtoBuf; var Contents = ProtoBuf.loadProtoFile (path).build(str); return Contents? Contents: null;};/** * create proto * @param path * @param str * @returns {*} */pg.createProto = function (path, str) {var Proto = new pg.loadProto< /span>(path, str); var data = new  span>Proto(); return data? data: null ;};/** * read msg * @param msg * @returns {Uint8Array} */pg.readMsg = function (msg) {if (!msg) {return null; } < span style="color:#cc7832;font-weight:bold;">var binary = new Uint8Array(msg ); var message = new Uint8Array(binary.byteLength- 4); for (var i = 0; i 4< span style="color:#cc7832;">; i++) {message[i] = binary[4 + i]; } return < /span>message;};/** * write msg * @param type * @param msg * @returns {Uint8Array} */ pg.writeMsg = function (type, msg) {if (!type || !msg) {return null; }    var binary = msg.toArrayBuffer( );    var byteLength = binary.byteLength + 4 ;    msg = new ArrayBuffer(4 + byteLength);    var view = new Uint8Array(msg);    var len = 2;    var tmp = new Uint8Array(len);    for (var i = 0; i < len; i++) {        tmp[i] = 0xff & (byteLength >> (8 * (len - i - 1)));        view[i] = tmp[i];    }    tmp = new Uint8Array(len);    for (var i = 0; i < len; i++) {        tmp[i] = 0xff & (type >> (8 * (len - i - 1)));        view[i + 2] = tmp[i];    }    tmp = new Uint8Array(binary);    for (var i = 0; i < byteLength; i++) {        view[i + 4] = tmp[i];    }    return msg;};/** * get msg type * @param msg * @returns {number} */pg.getMsgType = function (msg) {    if (!msg) {        return 0;    }    var bin ary = new Uint8Array(msg);    var type = 0;    for (var i = 0; i < 2; i++) {        type |= binary[i + 2] << (8 * (2 - i - 1));    }    return type;};

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3646 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.