send amount of ranked pixel in PixelReturn package
This commit is contained in:
parent
386218d722
commit
1b20d3f9e7
|
@ -39,11 +39,9 @@ function init() {
|
||||||
receivePixelUpdate(store, i, j, offset, color & 0x7F);
|
receivePixelUpdate(store, i, j, offset, color & 0x7F);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
SocketClient.on('pixelReturn', ({
|
SocketClient.on('pixelReturn',
|
||||||
retCode, wait, coolDownSeconds, pxlCnt,
|
(args) => receivePixelReturn(store, ...args),
|
||||||
}) => {
|
);
|
||||||
receivePixelReturn(store, retCode, wait, coolDownSeconds, pxlCnt);
|
|
||||||
});
|
|
||||||
SocketClient.on('cooldownPacket', (coolDown) => {
|
SocketClient.on('cooldownPacket', (coolDown) => {
|
||||||
store.dispatch(receiveCoolDown(coolDown));
|
store.dispatch(receiveCoolDown(coolDown));
|
||||||
});
|
});
|
||||||
|
|
|
@ -127,6 +127,7 @@ const HistorySelect = () => {
|
||||||
>
|
>
|
||||||
{times.map((value) => (
|
{times.map((value) => (
|
||||||
<option
|
<option
|
||||||
|
key={value}
|
||||||
value={value}
|
value={value}
|
||||||
>
|
>
|
||||||
{value}
|
{value}
|
||||||
|
|
|
@ -61,6 +61,7 @@ const SocialSettings = ({ done }) => {
|
||||||
{
|
{
|
||||||
blocked.map((bl) => (
|
blocked.map((bl) => (
|
||||||
<div
|
<div
|
||||||
|
key={bl[0]}
|
||||||
role="button"
|
role="button"
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|
|
@ -252,6 +252,7 @@ export async function drawByOffsets(
|
||||||
wait,
|
wait,
|
||||||
coolDown,
|
coolDown,
|
||||||
pxlCnt,
|
pxlCnt,
|
||||||
|
rankedPxlCnt,
|
||||||
retCode,
|
retCode,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -490,7 +490,7 @@ class SocketServer {
|
||||||
// check if captcha needed
|
// check if captcha needed
|
||||||
if (await needCaptcha(ip)) {
|
if (await needCaptcha(ip)) {
|
||||||
// need captcha
|
// need captcha
|
||||||
failureRet = PixelReturn.dehydrate(10, 0, 0);
|
failureRet = PixelReturn.dehydrate(10);
|
||||||
} else {
|
} else {
|
||||||
// (re)check for Proxy
|
// (re)check for Proxy
|
||||||
const allowed = await isIPAllowed(ip);
|
const allowed = await isIPAllowed(ip);
|
||||||
|
@ -504,7 +504,7 @@ class SocketServer {
|
||||||
// range banned
|
// range banned
|
||||||
failureStatus = 15;
|
failureStatus = 15;
|
||||||
}
|
}
|
||||||
failureRet = PixelReturn.dehydrate(failureStatus, 0, 0);
|
failureRet = PixelReturn.dehydrate(failureStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (failureRet !== null) {
|
if (failureRet !== null) {
|
||||||
|
@ -526,6 +526,7 @@ class SocketServer {
|
||||||
wait,
|
wait,
|
||||||
coolDown,
|
coolDown,
|
||||||
pxlCnt,
|
pxlCnt,
|
||||||
|
rankedPxlCnt,
|
||||||
retCode,
|
retCode,
|
||||||
} = await drawByOffsets(
|
} = await drawByOffsets(
|
||||||
ws.user,
|
ws.user,
|
||||||
|
@ -533,7 +534,13 @@ class SocketServer {
|
||||||
i, j,
|
i, j,
|
||||||
pixels,
|
pixels,
|
||||||
);
|
);
|
||||||
ws.send(PixelReturn.dehydrate(retCode, wait, coolDown, pxlCnt));
|
ws.send(PixelReturn.dehydrate(
|
||||||
|
retCode,
|
||||||
|
wait,
|
||||||
|
coolDown,
|
||||||
|
pxlCnt,
|
||||||
|
rankedPxlCnt,
|
||||||
|
));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RegisterCanvas.OP_CODE: {
|
case RegisterCanvas.OP_CODE: {
|
||||||
|
|
|
@ -8,22 +8,31 @@ export default {
|
||||||
const wait = data.getUint32(2);
|
const wait = data.getUint32(2);
|
||||||
const coolDownSeconds = data.getInt16(6);
|
const coolDownSeconds = data.getInt16(6);
|
||||||
const pxlCnt = data.getUint8(8);
|
const pxlCnt = data.getUint8(8);
|
||||||
return {
|
const rankedPxlCnt = data.getUint8(9);
|
||||||
|
return [
|
||||||
retCode,
|
retCode,
|
||||||
wait,
|
wait,
|
||||||
coolDownSeconds,
|
coolDownSeconds,
|
||||||
pxlCnt,
|
pxlCnt,
|
||||||
};
|
rankedPxlCnt,
|
||||||
|
];
|
||||||
},
|
},
|
||||||
dehydrate(retCode, wait, coolDown, pxlCnt) {
|
dehydrate(
|
||||||
|
retCode,
|
||||||
|
wait = 0,
|
||||||
|
coolDown = 0,
|
||||||
|
pxlCnt = 0,
|
||||||
|
rankedPxlCnt = 0,
|
||||||
|
) {
|
||||||
// Server (sender)
|
// Server (sender)
|
||||||
const buffer = Buffer.allocUnsafe(1 + 1 + 4 + 2 + 1);
|
const buffer = Buffer.allocUnsafe(1 + 1 + 4 + 2 + 1 + 1);
|
||||||
buffer.writeUInt8(OP_CODE, 0);
|
buffer.writeUInt8(OP_CODE, 0);
|
||||||
buffer.writeUInt8(retCode, 1);
|
buffer.writeUInt8(retCode, 1);
|
||||||
buffer.writeUInt32BE(wait, 2);
|
buffer.writeUInt32BE(wait, 2);
|
||||||
const coolDownSeconds = Math.round(coolDown / 1000);
|
const coolDownSeconds = Math.round(coolDown / 1000);
|
||||||
buffer.writeInt16BE(coolDownSeconds, 6);
|
buffer.writeInt16BE(coolDownSeconds, 6);
|
||||||
buffer.writeUInt8(pxlCnt, 8);
|
buffer.writeUInt8(pxlCnt, 8);
|
||||||
|
buffer.writeUInt8(rankedPxlCnt, 9);
|
||||||
return buffer;
|
return buffer;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -156,6 +156,7 @@ export function receivePixelReturn(
|
||||||
wait,
|
wait,
|
||||||
coolDownSeconds,
|
coolDownSeconds,
|
||||||
pxlCnt,
|
pxlCnt,
|
||||||
|
rankedPxlCnt,
|
||||||
) {
|
) {
|
||||||
clearTimeout(pixelTimeout);
|
clearTimeout(pixelTimeout);
|
||||||
|
|
||||||
|
@ -189,7 +190,7 @@ export function receivePixelReturn(
|
||||||
let type = 'error';
|
let type = 'error';
|
||||||
switch (retCode) {
|
switch (retCode) {
|
||||||
case 0:
|
case 0:
|
||||||
store.dispatch(placedPixels(pxlCnt));
|
store.dispatch(placedPixels(rankedPxlCnt));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
errorTitle = t`Invalid Canvas`;
|
errorTitle = t`Invalid Canvas`;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user