*Update dist

This commit is contained in:
Derrick Hammer 2023-02-06 05:51:41 -05:00
parent b4b30cbdea
commit 5b87187bc0
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 8 additions and 1 deletions

9
dist/peer.js vendored
View File

@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const socket_js_1 = __importDefault(require("./socket.js")); const socket_js_1 = __importDefault(require("./socket.js"));
const buffer_1 = require("buffer");
class Peer { class Peer {
_proxy; _proxy;
_peer; _peer;
@ -33,7 +34,10 @@ class Peer {
protocol: this._proxy.protocol, protocol: this._proxy.protocol,
async onopen(m) { async onopen(m) {
if (!m) { if (!m) {
m = Buffer.from([]); m = buffer_1.Buffer.from([]);
}
if (m instanceof Uint8Array) {
m = buffer_1.Buffer.from(m);
} }
self._socket = new socket_js_1.default({ self._socket = new socket_js_1.default({
remoteAddress: self._peer.rawStream.remoteHost, remoteAddress: self._peer.rawStream.remoteHost,
@ -55,6 +59,9 @@ class Peer {
}); });
const pipe = channel.addMessage({ const pipe = channel.addMessage({
async onmessage(m) { async onmessage(m) {
if (m instanceof Uint8Array) {
m = buffer_1.Buffer.from(m);
}
self._socket.emit("data", m); self._socket.emit("data", m);
await self._onreceive?.(m); await self._onreceive?.(m);
}, },