Skip to content

Commit 40e3c68

Browse files
authored
Merge pull request #13 from ajimenezdev/ConfigPortAndDisableWS
Configure Provider Port and DisableWebsocket
2 parents 7bd1252 + 6ae8650 commit 40e3c68

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ In order to connect to a real device you will need to set the IP of your compute
5050
export default withPerformanceMonitor(AwesomeChat, 'AwesomeChat', '192.168.1.10');
5151
```
5252

53+
By default the server is listening on port 8125 for event updates and 8126 for websocket.
54+
If you need to configure the port, because you are tunneling your request or similar, and or disable the Websocket communication, you can do it like this:
55+
56+
```
57+
export default withPerformanceMonitor(AwesomeChat, 'AwesomeChat', '192.168.1.10', undefined, undefined, 80, false);
58+
```
59+
5360
# How it works
5461

5562
The overall implementation is quite straight forward and simply involved passing the onRenderCallback values via a websocket server to finally render them in a fancy graph.

lib/provider.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import React, { Component } from 'react';
33
import hoistNonReactStatics from 'hoist-non-react-statics';
44

55
const Profiler = React.Profiler;
6-
export default (WrappedComponent, _id, ip = '127.0.0.1', events = ['mount', 'update'], showLogs = false) => {
7-
const remote = `http://${ip}:8125/value`;
6+
export default (WrappedComponent, _id, ip = '127.0.0.1', events = ['mount', 'update'], showLogs = false, port = 8125, enableWS = true) => {
7+
const remote = `http://${ip}:${port}/value`;
88
const log = (message) => {
99
if (showLogs) {
1010
console.log(message);
@@ -19,6 +19,7 @@ export default (WrappedComponent, _id, ip = '127.0.0.1', events = ['mount', 'upd
1919
}
2020

2121
componentDidMount() {
22+
if (!enableWS) return;
2223
this.socket = new WebSocket(`ws://${ip}:8126`);
2324
this.socket.onopen = function () {
2425
log('RNPM: connected');
@@ -45,7 +46,7 @@ export default (WrappedComponent, _id, ip = '127.0.0.1', events = ['mount', 'upd
4546
}
4647

4748
componentWillUnmount() {
48-
this.socket.close();
49+
this.socket && this.socket.close();
4950
}
5051

5152
logMeasurement = async (id, phase, actualDuration) => {

0 commit comments

Comments
 (0)