Separate Client in server and client part
Summary: This diff separates the concept of a Client as now on the UI, from the concept of a Client as known on the server, and makes all interactions with client and vice versa async. Reviewed By: timur-valiev Differential Revision: D31235682 fbshipit-source-id: 99089e9b390b4c5359f97f6f2b15bf4b182b6cb9
This commit is contained in:
committed by
Facebook GitHub Bot
parent
eab4804792
commit
740093d0d9
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
import EventEmitter from 'events';
|
||||
import Client from '../Client';
|
||||
import {Store} from '../reducers/index';
|
||||
import {Logger} from '../fb-interfaces/Logger';
|
||||
import ServerController from './comms/ServerController';
|
||||
@@ -91,10 +90,6 @@ export class FlipperServerImpl implements FlipperServer {
|
||||
this.android = new AndroidDeviceManager(this);
|
||||
this.ios = new IOSDeviceManager(this);
|
||||
|
||||
server.addListener('new-client', (client: Client) => {
|
||||
this.emit('client-connected', client);
|
||||
});
|
||||
|
||||
server.addListener('error', (err) => {
|
||||
this.emit('server-error', err);
|
||||
});
|
||||
@@ -263,6 +258,25 @@ export class FlipperServerImpl implements FlipperServer {
|
||||
}
|
||||
device.sendCommand(command);
|
||||
},
|
||||
'client-request': async (clientId, payload) => {
|
||||
this.server.connections.get(clientId)?.connection?.send(payload);
|
||||
},
|
||||
'client-request-response': async (clientId, payload) => {
|
||||
const client = this.server.connections.get(clientId);
|
||||
if (client && client.connection) {
|
||||
return await client.connection.sendExpectResponse(payload);
|
||||
}
|
||||
return {
|
||||
length: 0,
|
||||
error: {
|
||||
message: `Client '${clientId} is no longer connected, failed to deliver: ${JSON.stringify(
|
||||
payload,
|
||||
)}`,
|
||||
name: 'CLIENT_DISCONNECTED',
|
||||
stacktrace: '',
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
registerDevice(device: ServerDevice) {
|
||||
|
||||
Reference in New Issue
Block a user