websocket connection - make it work with new js sdk
Summary: we used to send plugins list with connect command, now we can respond to getPlugins request with new api. we still support old clients Reviewed By: jknoxville Differential Revision: D23625139 fbshipit-source-id: 37a24d0c83cd879d93287dd3a3d4d5d2f9477b34
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1d55b35dfd
commit
2b13899782
@@ -224,7 +224,8 @@ class Server extends EventEmitter {
|
|||||||
os: 'JSWebApp',
|
os: 'JSWebApp',
|
||||||
device: 'device',
|
device: 'device',
|
||||||
device_id: deviceId,
|
device_id: deviceId,
|
||||||
sdk_version: 1,
|
// if plugins != null -> we are using old api, where we send the list of plugins with connect message
|
||||||
|
sdk_version: plugins == null ? 4 : 1,
|
||||||
medium: 'FS_ACCESS',
|
medium: 'FS_ACCESS',
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
@@ -233,7 +234,8 @@ class Server extends EventEmitter {
|
|||||||
|
|
||||||
ws.on('message', (m: any) => {
|
ws.on('message', (m: any) => {
|
||||||
const parsed = JSON.parse(m.toString());
|
const parsed = JSON.parse(m.toString());
|
||||||
if (parsed.app === app) {
|
// non-null payload id means response to prev request, it's handled in connection
|
||||||
|
if (parsed.app === app && parsed.payload?.id == null) {
|
||||||
const message = JSON.stringify(parsed.payload);
|
const message = JSON.stringify(parsed.payload);
|
||||||
if (resolvedClient) {
|
if (resolvedClient) {
|
||||||
resolvedClient.onMessage(message);
|
resolvedClient.onMessage(message);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export class WebsocketClientFlipperConnection<M>
|
|||||||
connStatusSubscribers: Set<ISubscriber<ConnectionStatus>> = new Set();
|
connStatusSubscribers: Set<ISubscriber<ConnectionStatus>> = new Set();
|
||||||
connStatus: ConnectionStatus;
|
connStatus: ConnectionStatus;
|
||||||
app: string;
|
app: string;
|
||||||
plugins: string[] = [];
|
plugins: string[] | undefined = undefined;
|
||||||
|
|
||||||
constructor(ws: WebSocket, app: string, plugins: string[]) {
|
constructor(ws: WebSocket, app: string, plugins: string[]) {
|
||||||
this.websocket = ws;
|
this.websocket = ws;
|
||||||
@@ -66,7 +66,7 @@ export class WebsocketClientFlipperConnection<M>
|
|||||||
|
|
||||||
subscriber.onSubscribe(() => {});
|
subscriber.onSubscribe(() => {});
|
||||||
|
|
||||||
if (method === 'getPlugins') {
|
if (method === 'getPlugins' && this.plugins != null) {
|
||||||
subscriber.onComplete({
|
subscriber.onComplete({
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
success: {plugins: this.plugins},
|
success: {plugins: this.plugins},
|
||||||
|
|||||||
Reference in New Issue
Block a user