Log error message when there are zero connected clients
Reviewed By: frantic Differential Revision: D5789198 fbshipit-source-id: 0c927fe7efc204b7f1173da97cc69262867e632b
This commit is contained in:
parent
ae60ae4074
commit
c88b2b2c65
|
@ -11,6 +11,7 @@
|
||||||
const url = require('url');
|
const url = require('url');
|
||||||
const WebSocketServer = require('ws').Server;
|
const WebSocketServer = require('ws').Server;
|
||||||
const PROTOCOL_VERSION = 2;
|
const PROTOCOL_VERSION = 2;
|
||||||
|
const notifier = require('node-notifier');
|
||||||
|
|
||||||
function parseMessage(data, binary) {
|
function parseMessage(data, binary) {
|
||||||
if (binary) {
|
if (binary) {
|
||||||
|
@ -76,6 +77,14 @@ function attachToServer(server, path) {
|
||||||
method: message.method,
|
method: message.method,
|
||||||
params: message.params,
|
params: message.params,
|
||||||
};
|
};
|
||||||
|
if (clients.size === 0) {
|
||||||
|
notifier.notify({
|
||||||
|
'title': 'React Native: No apps connected',
|
||||||
|
'message': `Sending '${message.method}' to all React Native apps ` +
|
||||||
|
'failed. Make sure your app is running in the simulator ' +
|
||||||
|
'or on a phone connected via USB.'
|
||||||
|
});
|
||||||
|
}
|
||||||
for (const [otherId, otherWs] of clients) {
|
for (const [otherId, otherWs] of clients) {
|
||||||
if (otherId !== broadcasterId) {
|
if (otherId !== broadcasterId) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue