Skip to content

Commit

Permalink
Log error message when there are zero connected clients
Browse files Browse the repository at this point in the history
Reviewed By: frantic

Differential Revision: D5789198

fbshipit-source-id: 0c927fe7efc204b7f1173da97cc69262867e632b
  • Loading branch information
hrp authored and facebook-github-bot committed Sep 8, 2017
1 parent ae60ae4 commit c88b2b2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions local-cli/server/util/messageSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c88b2b2

Please sign in to comment.