Skip to content

Commit

Permalink
WebSocket: use some over find.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpacingBat3 committed May 4, 2024
1 parent dedd298 commit 4345123
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sources/transport/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ export class WebSocketProtocol extends Protocol<Server,"WebSocket"> {
parsedData = packetString;
}
}
const hookParsed = knownPacketID.codes.find(code => {
const hookParsed = knownPacketID.codes.some(code => {
if(code === "DEEP_LINK")
return knownPacketID.types.find(type => {
return knownPacketID.types.some(type => {
if(isMessage(parsedData,code,type)) {
const message = Object.freeze(parsedData);
const [hooks,isActive] = [
Expand All @@ -180,7 +180,7 @@ export class WebSocketProtocol extends Protocol<Server,"WebSocket"> {
return true;
}
return false;
}) !== undefined;
});
else if(isMessage(parsedData,code)) {
const message = Object.freeze(parsedData);
const [hooks,isActive] = [
Expand All @@ -203,12 +203,12 @@ export class WebSocketProtocol extends Protocol<Server,"WebSocket"> {
return true;
}
return false;
}) !== undefined;
});
if(!hookParsed)
// Unknown response error
if(isMessage(parsedData)) {
const type = typeof parsedData.args["type"] === "string" ?
parsedData.cmd+":"+parsedData.args["type"] : parsedData.cmd;
parsedData.cmd+"_"+parsedData.args["type"] : parsedData.cmd;
const msg = `Request of type: '${type}' is currently not supported.`;
this.error(msg);
this.debug("Request %s", JSON.stringify(parsedData,undefined,4));
Expand Down

0 comments on commit 4345123

Please sign in to comment.