Cleaned up some socket request code
parent
10c3427355
commit
a7340fa155
|
|
@ -275,7 +275,18 @@ export default class RoomClient
|
|||
{
|
||||
logger.debug('getChatHistory()');
|
||||
|
||||
return this.sendRequest('chat-history', {})
|
||||
return this.sendRequest('chat-history')
|
||||
.then((response) =>
|
||||
{
|
||||
const { chatHistory } = response;
|
||||
|
||||
if (chatHistory.length > 0)
|
||||
{
|
||||
logger.debug('Got chat history');
|
||||
this._dispatch(
|
||||
stateActions.addChatHistory(chatHistory));
|
||||
}
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
logger.error('getChatHistory() | failed: %o', error);
|
||||
|
|
@ -292,7 +303,18 @@ export default class RoomClient
|
|||
{
|
||||
logger.debug('getFileHistory()');
|
||||
|
||||
return this.sendRequest('file-history', {})
|
||||
return this.sendRequest('file-history')
|
||||
.then((response) =>
|
||||
{
|
||||
const { fileHistory } = response;
|
||||
|
||||
if (fileHistory.length > 0)
|
||||
{
|
||||
logger.debug('Got files history');
|
||||
|
||||
this._dispatch(stateActions.addFileHistory(fileHistory));
|
||||
}
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
logger.error('getFileHistory() | failed: %o', error);
|
||||
|
|
@ -1169,18 +1191,6 @@ export default class RoomClient
|
|||
stateActions.addResponseMessage({ ...chatMessage, peerName }));
|
||||
});
|
||||
|
||||
this._signalingSocket.on('chat-history-receive', (data) =>
|
||||
{
|
||||
const { chatHistory } = data;
|
||||
|
||||
if (chatHistory.length > 0)
|
||||
{
|
||||
logger.debug('Got chat history');
|
||||
this._dispatch(
|
||||
stateActions.addChatHistory(chatHistory));
|
||||
}
|
||||
});
|
||||
|
||||
this._signalingSocket.on('file-receive', (data) =>
|
||||
{
|
||||
const payload = data.file;
|
||||
|
|
@ -1191,18 +1201,6 @@ export default class RoomClient
|
|||
text : `${payload.name} shared a file`
|
||||
}));
|
||||
});
|
||||
|
||||
this._signalingSocket.on('file-history-receive', (data) =>
|
||||
{
|
||||
const files = data.fileHistory;
|
||||
|
||||
if (files.length > 0)
|
||||
{
|
||||
logger.debug('Got files history');
|
||||
|
||||
this._dispatch(stateActions.addFileHistory(files));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_joinRoom({ displayName, device })
|
||||
|
|
|
|||
|
|
@ -265,14 +265,8 @@ class Room extends EventEmitter
|
|||
|
||||
signalingPeer.socket.on('chat-history', (request, cb) =>
|
||||
{
|
||||
// Return no error
|
||||
cb(null);
|
||||
|
||||
// Return to socket
|
||||
signalingPeer.socket.emit(
|
||||
'chat-history-receive',
|
||||
{ chatHistory: this._chatHistory }
|
||||
);
|
||||
// Return to sender
|
||||
cb(null, { chatHistory: this._chatHistory });
|
||||
});
|
||||
|
||||
signalingPeer.socket.on('send-file', (request, cb) =>
|
||||
|
|
@ -300,16 +294,8 @@ class Room extends EventEmitter
|
|||
|
||||
signalingPeer.socket.on('file-history', (request, cb) =>
|
||||
{
|
||||
// Return no error
|
||||
cb(null);
|
||||
|
||||
// Return to socket
|
||||
signalingPeer.socket.emit(
|
||||
'file-history-receive',
|
||||
{
|
||||
fileHistory : this._fileHistory
|
||||
}
|
||||
);
|
||||
// Return to sender
|
||||
cb(null, { fileHistory : this._fileHistory });
|
||||
});
|
||||
|
||||
signalingPeer.socket.on('raisehand-message', (request, cb) =>
|
||||
|
|
|
|||
Loading…
Reference in New Issue