HEX
Server: Apache/2.2.34 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0910052141
System: Linux Kou-Etsu-Dou 4.4.59+ #25556 SMP PREEMPT Thu Mar 4 18:03:46 CST 2021 x86_64
User: hosam (1026)
PHP: 7.2.29
Disabled: NONE
Upload Files
File: /volume1/@appstore/Contacts/nodejs/pushserver/packet.js
const e=4;function t(t,n){const o=Buffer.byteLength(n),r=Buffer.alloc(o+e);r.writeUInt32BE(o,0),r.write(n,e,o),t.write(r)||console.error("write socket failed")}function n(n,o){let r=new Buffer("");n.on("data",c=>{for(r=Buffer.concat([r,c],r.length+c.length);r.length>0;){const c=r.readUInt32BE();if(r.length-e<c)break;const a=r.slice(e,c+e);let l;r=r.slice(c+e);try{l=JSON.parse(a.toString())}catch(e){console.warn("parse payload failed",a.toString(),e)}const i=o(l);t(n,JSON.stringify(i))}})}module.exports={HEADER_SIZE:e,handlePacketFromSocket:n,writePacket:t};