Skip to content

Commit

Permalink
fix: Adjust websockets messages to match server (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathonherbert committed Nov 27, 2020
1 parent 12925e6 commit 493486e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/ts/services/adapters/TyperighterWsAdapter.ts
Expand Up @@ -9,22 +9,22 @@ import {
TRequestCompleteCallback
} from "../../interfaces/IMatcherAdapter";

const MATCHER_RESPONSE = "MATCHER_RESPONSE" as const;
const REQUEST_ERROR = "REQUEST_ERROR" as const;
const REQUEST_COMPLETE = "REQUEST_COMPLETE" as const;
const CHECK_RESPONSE = "CHECK_RESPONSE" as const;
const CHECK_ERROR = "CHECK_ERROR" as const;
const CHECK_COMPLETE = "CHECK_COMPLETE" as const;

interface ISocketResponse extends ITypeRighterResponse {
type: typeof MATCHER_RESPONSE;
type: typeof CHECK_RESPONSE;
}

interface ISocketError {
type: typeof REQUEST_ERROR;
type: typeof CHECK_ERROR;
id: string | undefined;
message: string;
}

interface ISocketWorkComplete {
type: typeof REQUEST_COMPLETE;
type: typeof CHECK_COMPLETE;
}

type TSocketMessage = ISocketResponse | ISocketError | ISocketWorkComplete;
Expand Down Expand Up @@ -92,19 +92,19 @@ class TyperighterWsAdapter extends TyperighterAdapter
try {
const socketMessage: TSocketMessage = JSON.parse(message.data);
switch (socketMessage.type) {
case REQUEST_ERROR: {
case CHECK_ERROR: {
return onRequestError({
requestId,
blockId: socketMessage.id,
message: socketMessage.message,
categoryIds: []
});
}
case MATCHER_RESPONSE: {
case CHECK_RESPONSE: {
this.responseBuffer.push(socketMessage);
return this.throttledHandleResponse(requestId, onMatchesReceived);
}
case REQUEST_COMPLETE: {
case CHECK_COMPLETE: {
this.flushResponseBuffer(requestId, onMatchesReceived);
return onRequestComplete(requestId);
}
Expand Down

0 comments on commit 493486e

Please sign in to comment.