Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async _p2pSend (peerAddress, obj) {
// log.t(this.me() + ' >>> ' + this.nick(peerAddress) + ' - ' + obj.type)
return this._p2p.publishReliable(
[peerAddress],
msgpack.encode(obj).toString('base64')
)
}
async _p2pSendAll (obj) {
// log.t(this.me() + ' >>> ' + this._peerList + ' - ' + obj.type)
return this._p2p.publishReliable(
this._peerList,
msgpack.encode(obj).toString('base64')
)
}
const ipcMsg = async (type, data) => {
const resp = await client.call(
msgpack.encode({ type, data }))
if (!resp) {
console.error('bad ipc response', resp)
process.exit(1)
}
if (resp.byteLength) {
return msgpack.decode(resp)
}
}
onPressEnter = value => {
this.setState({ value: value.target.value });
storeState(this.props.uuid, this.state, { value: value.target.value });
this.props.socket.emit(this.props.uuid + '#enter', msgpack.encode(value.target.value));
};
send(message) {
const serializedMessage = msgpack.encode(message);
const header = new Uint32Array([ serializedMessage.byteLength ]);
this.pipe.write(Buffer.from(header.buffer));
this.pipe.write(serializedMessage);
}
}
write(type, payload) {
const data = msgpack.encode([ String(type), payload ]);
this.socket.write(data);
}
public write(reqId: number, method: string, args: any[]) {
const req = [0, reqId, method, args];
const encoded = msgpack.encode(req);
this.socket.send(encoded);
}
getEncodedState () {
return msgpack.encode( utils.toJSON( this.state ) )
}
module.exports.decode = function (str) {
str = new Uint8Array(str);
var object = msgpack.decode(str, options);
if (Array.isArray(object)) {
var len = object.length;
for (var i = 0; i < len; i++) {
decompressSinglePacket(object[i]);
}
} else {
decompressSinglePacket(object);
}
return object;
};
module.exports.decode = function (str) {
str = new Uint8Array(str);
var object = msgpack.decode(str, options);
if (Array.isArray(object)) {
var len = object.length;
for (var i = 0; i < len; i++) {
decompressSinglePacket(object[i]);
}
} else {
decompressSinglePacket(object);
}
return object;
};