Log error message when there are zero connected clients

Reviewed By: frantic

Differential Revision: D5789198

fbshipit-source-id: 0c927fe7efc204b7f1173da97cc69262867e632b
This commit is contained in:
Hiten Parmar 2017-09-08 15:15:51 -07:00 committed by Facebook Github Bot
parent ae60ae4074
commit c88b2b2c65
1 changed files with 9 additions and 0 deletions

View File

@ -11,6 +11,7 @@
const url = require('url');
const WebSocketServer = require('ws').Server;
const PROTOCOL_VERSION = 2;
const notifier = require('node-notifier');
function parseMessage(data, binary) {
if (binary) {
@ -76,6 +77,14 @@ function attachToServer(server, path) {
method: message.method,
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) {
if (otherId !== broadcasterId) {
try {