Host and port as function args
Summary: ^ Before this change, the client assumed the host and port came from location.host which is fine on the browser. In all other cases, that object/properties may be undefined. As such, add host and port as function args and use that instead. Reviewed By: passy Differential Revision: D36440423 fbshipit-source-id: 5f931f1d610d583db6a2e549e1213585f0d03dee
This commit is contained in:
committed by
Facebook GitHub Bot
parent
aca1aca29c
commit
23b551c8bf
@@ -25,6 +25,8 @@ export enum FlipperServerState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createFlipperServer(
|
export function createFlipperServer(
|
||||||
|
host: string,
|
||||||
|
port: number,
|
||||||
onStateChange: (state: FlipperServerState) => void,
|
onStateChange: (state: FlipperServerState) => void,
|
||||||
): Promise<FlipperServer> {
|
): Promise<FlipperServer> {
|
||||||
onStateChange(FlipperServerState.CONNECTING);
|
onStateChange(FlipperServerState.CONNECTING);
|
||||||
@@ -38,7 +40,7 @@ export function createFlipperServer(
|
|||||||
|
|
||||||
const eventEmitter = new EventEmitter();
|
const eventEmitter = new EventEmitter();
|
||||||
|
|
||||||
const socket = new ReconnectingWebSocket(`ws://${location.host}`);
|
const socket = new ReconnectingWebSocket(`ws://${host}:${port}`);
|
||||||
const pendingRequests: Map<
|
const pendingRequests: Map<
|
||||||
number,
|
number,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ async function start() {
|
|||||||
setLoggerInstance(logger);
|
setLoggerInstance(logger);
|
||||||
|
|
||||||
const flipperServer = await createFlipperServer(
|
const flipperServer = await createFlipperServer(
|
||||||
|
location.hostname,
|
||||||
|
parseInt(location.port, 10),
|
||||||
(state: FlipperServerState) => {
|
(state: FlipperServerState) => {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case FlipperServerState.CONNECTING:
|
case FlipperServerState.CONNECTING:
|
||||||
|
|||||||
Reference in New Issue
Block a user