Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
xhayper committed Aug 18, 2022
1 parent a7e589f commit 8cbef47
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/transport/IPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export enum IPC_OPCODE {
}

export type FormatFunction = (
id: number
id: number,
) => [path: string, skipCheck?: boolean];

export type IPCTransportOptions = {
Expand All @@ -34,7 +34,7 @@ const defaultPathList: FormatFunction[] = [
const { XDG_RUNTIME_DIR, TMPDIR, TMP, TEMP } = Deno.env.toObject();

const prefix = Deno.realPathSync(
XDG_RUNTIME_DIR ?? TMPDIR ?? TMP ?? TEMP ?? `${path.sep}tmp`
XDG_RUNTIME_DIR ?? TMPDIR ?? TMP ?? TEMP ?? `${path.sep}tmp`,
);
return [path.join(prefix, `discord-ipc-${id}`)];
},
Expand All @@ -46,7 +46,7 @@ const defaultPathList: FormatFunction[] = [
const { XDG_RUNTIME_DIR, TMPDIR, TMP, TEMP } = Deno.env.toObject();

const prefix = Deno.realPathSync(
XDG_RUNTIME_DIR ?? TMPDIR ?? TMP ?? TEMP ?? `${path.sep}tmp`
XDG_RUNTIME_DIR ?? TMPDIR ?? TMP ?? TEMP ?? `${path.sep}tmp`,
);
return [path.join(prefix, "snap.discord", `discord-ipc-${id}`)];
},
Expand All @@ -58,7 +58,7 @@ const defaultPathList: FormatFunction[] = [
const { XDG_RUNTIME_DIR, TMPDIR, TMP, TEMP } = Deno.env.toObject();

const prefix = Deno.realPathSync(
XDG_RUNTIME_DIR ?? TMPDIR ?? TMP ?? TEMP ?? `${path.sep}tmp`
XDG_RUNTIME_DIR ?? TMPDIR ?? TMP ?? TEMP ?? `${path.sep}tmp`,
);
return [
path.join(prefix, "app", "com.discordapp.Discord", `discord-ipc-${id}`),
Expand Down Expand Up @@ -108,7 +108,7 @@ export class IPCTransport extends Transport {
};

const handleSocketId = async (
id: number
id: number,
): Promise<net.Socket | null> => {
const [socketPath, skipCheck] = formatFunc(id);

Expand Down Expand Up @@ -155,7 +155,7 @@ export class IPCTransport extends Transport {
v: 1,
client_id: this.client.clientId,
},
IPC_OPCODE.HANDSHAKE
IPC_OPCODE.HANDSHAKE,
);

let chunk: Buffer | null;
Expand All @@ -176,13 +176,11 @@ export class IPCTransport extends Transport {

if (this.client.debug) {
console.log(
`SERVER => CLIENT | Recieved ${
data.length
} bytes, missing ${sizeRemaining} bytes, left over ${
`SERVER => CLIENT | Recieved ${data.length} bytes, missing ${sizeRemaining} bytes, left over ${
remainingData?.length ?? 0
} bytes | Whole packet length: ${
wholeData.length
}, Required packet length: ${length + 8}`
} bytes | Whole packet length: ${wholeData.length}, Required packet length: ${
length + 8
}`,
);
}

Expand All @@ -203,7 +201,7 @@ export class IPCTransport extends Transport {
if (this.client.debug) {
console.debug(
`SERVER => CLIENT | OPCODE.${IPC_OPCODE[packet.op]} |`,
packet.data
packet.data,
);
}

Expand Down

0 comments on commit 8cbef47

Please sign in to comment.