Compare commits

..

No commits in common. "58266bcb7fc7405fe00f47ee3dc4077d6c4b0726" and "bc5d85d6d46a2d760665e1690365d36f87763100" have entirely different histories.

3 changed files with 8 additions and 9 deletions

View File

@ -1,5 +1,5 @@
## Install dev and compilation dependencies, build files ## Install dev and compilation dependencies, build files
FROM alpine:3.20 as build FROM alpine:3.18 as build
WORKDIR /calckey WORKDIR /calckey
# Install compilation dependencies # Install compilation dependencies
@ -20,7 +20,7 @@ RUN env NODE_ENV=production sh -c "pnpm run build"
RUN pnpm i --prod --frozen-lockfile RUN pnpm i --prod --frozen-lockfile
## Runtime container ## Runtime container
FROM alpine:3.20 FROM alpine:3.18
WORKDIR /calckey WORKDIR /calckey
# Install runtime dependencies # Install runtime dependencies

View File

@ -6,7 +6,7 @@
"type": "git", "type": "git",
"url": "https://git.astolfo.cool/natty/calckey" "url": "https://git.astolfo.cool/natty/calckey"
}, },
"packageManager": "pnpm@9.1.2", "packageManager": "pnpm@8.6.3+sha512.d18e277ae8072091046bccbca0931f77dc3080791cd6122ae890bf504125d8af76b37fb33da287dba9fbbb6da6ebb13e314e9fa4a464c7effe3d8599cebe7243",
"private": true, "private": true,
"scripts": { "scripts": {
"rebuild": "pnpm run clean && pnpm node ./scripts/build-greet.js && pnpm -r run build", "rebuild": "pnpm run clean && pnpm node ./scripts/build-greet.js && pnpm -r run build",

View File

@ -13,7 +13,7 @@ let serial: bigint = BigInt(0);
const logger = new Logger("RpcLog"); const logger = new Logger("RpcLog");
function getRpcClient(): Socket { function getRpcClient(): Socket {
if (client != null) { if (client) {
return client; return client;
} }
@ -85,9 +85,6 @@ function getRpcClient(): Socket {
} }
async function rpcCall<D, T>(method: string, data: D): Promise<T> { async function rpcCall<D, T>(method: string, data: D): Promise<T> {
const currentSerial = serial;
serial = serial + BigInt(1);
const header = new Uint8Array([77]); const header = new Uint8Array([77]);
const textEncoder = new TextEncoder(); const textEncoder = new TextEncoder();
const methodBuf = textEncoder.encode(method); const methodBuf = textEncoder.encode(method);
@ -102,7 +99,7 @@ async function rpcCall<D, T>(method: string, data: D): Promise<T> {
packetBuf.set(dataBuf, header.length + serialLength + sizeLength + methodBuf.length + sizeLength); packetBuf.set(dataBuf, header.length + serialLength + sizeLength + methodBuf.length + sizeLength);
const packetDataView = new DataView(packetBuf.buffer); const packetDataView = new DataView(packetBuf.buffer);
packetDataView.setBigUint64(header.length, currentSerial); packetDataView.setBigUint64(header.length, serial);
packetDataView.setUint32(header.length + serialLength, methodBuf.length); packetDataView.setUint32(header.length + serialLength, methodBuf.length);
packetDataView.setUint32(header.length + serialLength + sizeLength + methodBuf.length, dataBuf.length); packetDataView.setUint32(header.length + serialLength + sizeLength + methodBuf.length, dataBuf.length);
@ -110,11 +107,13 @@ async function rpcCall<D, T>(method: string, data: D): Promise<T> {
client.write(packetBuf); client.write(packetBuf);
const fut = new Promise((resolve, reject) => { const fut = new Promise((resolve, reject) => {
client.once(`mag-data:${currentSerial}`, resolve); client.once(`mag-data:${serial}`, resolve);
client.once("close", reject); client.once("close", reject);
client.once("error", reject); client.once("error", reject);
}); });
serial++;
const result = await fut as { success: false, data: any } | { success: true, data: T }; const result = await fut as { success: false, data: any } | { success: true, data: T };
if (!result.success) { if (!result.success) {