Get server host in setupDevtools for Android

Summary:
The `setupDevtools` for Android looks coming on [v0.30](22fbb6d46d), currently we need to run `adb reverse tcp:8097 tcp:8097`, I think get host IP (`10.0.2.2`, Genymotion: `10.0.3.2`) for Android will be better. (it can be found in `AndroidConstants` native module)
Closes https://github.com/facebook/react-native/pull/8811

Differential Revision: D3586177

Pulled By: javache

fbshipit-source-id: 3bfe04391b0fea608e4d3deab03dd376fab8727c
This commit is contained in:
Jhen 2016-07-19 05:43:16 -07:00 коммит произвёл Facebook Github Bot 1
Родитель 875d5d2364
Коммит 46417dd26a
1 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -11,10 +11,17 @@
*/
'use strict';
var Platform = require('Platform');
var NativeModules = require('NativeModules');
function setupDevtools() {
var messageListeners = [];
var closeListeners = [];
var ws = new window.WebSocket('ws://localhost:8097/devtools');
var hostname = 'localhost';
if (Platform.OS === 'android' && NativeModules.AndroidConstants) {
hostname = NativeModules.AndroidConstants.ServerHost.split(':')[0];
}
var ws = new window.WebSocket('ws://' + hostname + ':8097/devtools');
// this is accessed by the eval'd backend code
var FOR_BACKEND = { // eslint-disable-line no-unused-vars
resolveRNStyle: require('flattenStyle'),