set up websocket and emoji in chat component

This commit is contained in:
Ginger Wong
2020-08-13 09:28:47 -07:00
parent 7a1512ef6b
commit 3814c24cab
7 changed files with 156 additions and 124 deletions

View File

@@ -4,7 +4,7 @@ const URL_WEBSOCKET = `${location.protocol === 'https:' ? 'wss' : 'ws'}://${loca
const TIMER_WEBSOCKET_RECONNECT = 5000; // ms
const CALLBACKS = {
export const CALLBACKS = {
RAW_WEBSOCKET_MESSAGE_RECEIVED: 'rawWebsocketMessageReceived',
WEBSOCKET_CONNECTED: 'websocketConnected',
WEBSOCKET_DISCONNECTED: 'websocketDisconnected',
@@ -42,7 +42,7 @@ class Websocket {
}
}
// Interface with other components
// Outbound: Other components can pass an object to `send`.
@@ -51,7 +51,7 @@ class Websocket {
if (!message.type || !SOCKET_MESSAGE_TYPES[message.type]) {
console.warn(`Outbound message: Unknown socket message type: "${message.type}" sent.`);
}
const messageJSON = JSON.stringify(message);
this.websocket.send(messageJSON);
}
@@ -114,7 +114,7 @@ class Websocket {
} catch (e) {
console.log(e)
}
// Send PONGs
if (model.type === SOCKET_MESSAGE_TYPES.PING) {
this.sendPong();
@@ -136,4 +136,4 @@ class Websocket {
};
}
export default Websocket;
export default Websocket;