Migrate from socket.io
Reviewed By: passy Differential Revision: D34787674 fbshipit-source-id: 63d7c166ea29d14c96f0646a045e3f6fa93472e2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6ec3771824
commit
f85def32fb
@@ -54,3 +54,4 @@ export * from './settings';
|
||||
export * from './PluginDetails';
|
||||
export * from './doctor';
|
||||
export * from './ServerAddOn';
|
||||
export * from './transport';
|
||||
|
||||
49
desktop/flipper-common/src/transport.tsx
Normal file
49
desktop/flipper-common/src/transport.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {FlipperServerCommands, FlipperServerEvents} from './server-types';
|
||||
|
||||
type GenericWebSocketMessage<E = string, T = unknown> = {
|
||||
event: E;
|
||||
payload: T;
|
||||
};
|
||||
|
||||
export type ExecWebSocketMessage = GenericWebSocketMessage<
|
||||
'exec',
|
||||
{
|
||||
[K in keyof FlipperServerCommands]: {
|
||||
id: number;
|
||||
command: K;
|
||||
args: Parameters<FlipperServerCommands[K]>;
|
||||
};
|
||||
}[keyof FlipperServerCommands]
|
||||
>;
|
||||
|
||||
export type ExecResponseWebSocketMessage = GenericWebSocketMessage<
|
||||
'exec-response',
|
||||
{id: number; data: unknown}
|
||||
>;
|
||||
|
||||
export type ExecResponseErrorWebSocketMessage = GenericWebSocketMessage<
|
||||
'exec-response-error',
|
||||
{id: number; data: unknown}
|
||||
>;
|
||||
|
||||
export type ServerEventWebSocketMessage = GenericWebSocketMessage<
|
||||
'server-event',
|
||||
{
|
||||
[K in keyof FlipperServerEvents]: {event: K; data: FlipperServerEvents[K]};
|
||||
}[keyof FlipperServerEvents]
|
||||
>;
|
||||
|
||||
export type ClientWebSocketMessage = ExecWebSocketMessage;
|
||||
export type ServerWebSocketMessage =
|
||||
| ExecResponseWebSocketMessage
|
||||
| ExecResponseErrorWebSocketMessage
|
||||
| ServerEventWebSocketMessage;
|
||||
Reference in New Issue
Block a user