Skip to content

Commit

Permalink
Send error responses for socket clients (#205)
Browse files Browse the repository at this point in the history
* Send errors from server

* Ensure messages are not blank in client
  • Loading branch information
baileytincher authored Apr 30, 2021
1 parent 3bce1fd commit b1f483c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/src/socket/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class ActuallyColabSocketClient extends EventEmitter<ActuallyColabEventLi
};

this.socketClient.onmessage = (message): void => {
if (typeof message.data === 'string') {
if (typeof message.data === 'string' && message.data !== '') {
const eventData: ActuallyColabEventData = JSON.parse(message.data);
switch (eventData.action) {
case 'notebook_opened': {
Expand Down
2 changes: 1 addition & 1 deletion client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


"@actually-colab/editor-types@file:../types":
version "0.1.0"
version "0.2.1"

"@types/anymatch@*":
version "1.3.1"
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@shallot/aws": "^1.0.6",
"@shallot/aws-websocket-wrapper": "^1.0.7",
"@shallot/aws-websocket-wrapper": "^1.0.9",
"@shallot/http-error-handler": "^1.0.2",
"@shallot/rest-wrapper": "^1.1.3",
"aws-sdk": "^2.842.0",
Expand Down
11 changes: 11 additions & 0 deletions server/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,74 +213,85 @@ functions:

events:
- websocket:
routeResponseSelectionExpression: $default
route: open_notebook

socket-close-notebook:
handler: src/socket/notebook/close-notebook.handler

events:
- websocket:
routeResponseSelectionExpression: $default
route: close_notebook

socket-share-notebook:
handler: src/socket/notebook/share-notebook.handler

events:
- websocket:
routeResponseSelectionExpression: $default
route: share_notebook

socket-edit-cell:
handler: src/socket/cell/edit-cell.handler

events:
- websocket:
routeResponseSelectionExpression: $default
route: edit_cell

socket-create-cell:
handler: src/socket/cell/create-cell.handler

events:
- websocket:
routeResponseSelectionExpression: $default
route: create_cell

socket-lock-cell:
handler: src/socket/cell/lock-cell.handler

events:
- websocket:
routeResponseSelectionExpression: $default
route: lock_cell

socket-unlock-cell:
handler: src/socket/cell/unlock-cell.handler

events:
- websocket:
routeResponseSelectionExpression: $default
route: unlock_cell

socket-update-output:
handler: src/socket/cell/update-output.handler

events:
- websocket:
routeResponseSelectionExpression: $default
route: update_output

socket-share-workshop:
handler: src/socket/workshop/share-workshop.handler

events:
- websocket:
routeResponseSelectionExpression: $default
route: share_workshop

socket-start-workshop:
handler: src/socket/workshop/start-workshop.handler

events:
- websocket:
routeResponseSelectionExpression: $default
route: start_workshop

send_chat_message:
handler: src/socket/chat/send-chat.handler

events:
- websocket:
routeResponseSelectionExpression: $default
route: send_chat_message
2 changes: 1 addition & 1 deletion server/src/socket/client-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
DUser,
DActiveSession,
} from '@actually-colab/editor-types';
import type { WebSocketRequestContext } from './connection';
import type { WebSocketRequestContext } from '@shallot/aws-websocket-wrapper';

import { ApiGatewayManagementApi } from 'aws-sdk';

Expand Down
8 changes: 4 additions & 4 deletions server/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -601,10 +601,10 @@
uuid "^8.3.2"
write-file-atomic "^3.0.3"

"@shallot/aws-websocket-wrapper@^1.0.7":
version "1.0.7"
resolved "https://registry.yarnpkg.com/@shallot/aws-websocket-wrapper/-/aws-websocket-wrapper-1.0.7.tgz#1595fe5aa22c1e9099af82b0173eebbe09ca3c40"
integrity sha512-cHLGBrBkA4NW7xgbaCbmdM9h3TFznb3aPdvQIx2Ahjp3YGSDHR7/3ASrlDA26xEFgrsaIjD0idreMk2fVJ3pqw==
"@shallot/aws-websocket-wrapper@^1.0.9":
version "1.0.9"
resolved "https://registry.yarnpkg.com/@shallot/aws-websocket-wrapper/-/aws-websocket-wrapper-1.0.9.tgz#3eeabc54ae208d0548bf2c6c64dfa14db47680a1"
integrity sha512-0gLd4/pQanbvMhJrokgA1gahZPlvtgHSpXGGK9hRfaxmOKNfwp4rHci9MINGfWzgpyznlcs+twpRHDowk5tauA==
dependencies:
"@shallot/aws" "^1.0.6"
"@shallot/http-error-handler" "^1.0.2"
Expand Down

0 comments on commit b1f483c

Please sign in to comment.