How to use the dotnetify/react-native.hubServerUrl function in dotnetify

To help you get started, we’ve selected a few dotnetify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dsuryd / dotNetify-react-native-demo / App.js View on Github external
import ScreenTracker from './src/ScreenTracker';
import Authentication from './src/Authentication';

const androidEmulatorServerUrl = 'http://169.254.80.80:5000';
const liveServerUrl = 'http://dotnetify.net';
const serverUrl = Platform.OS === 'android' ? androidEmulatorServerUrl : liveServerUrl;

dotnetify.debug = true;

// Live server is still running an older signalR version, which requires a different SignalR client library.
if (serverUrl == liveServerUrl) {
  dotnetify.hubLib = signalRnetfx;
  dotnetify.hubServerUrl = serverUrl + '/signalr';
  dotnetify.hubOptions.pingInterval = 60000;
}
else dotnetify.hubServerUrl = serverUrl;

Authentication.url = serverUrl + '/token';

export default class App extends React.Component {
  state = { appLoaded: false, connectionStatus: null };

  constructor(props) {
    super(props);

    dotnetify.connectionStateHandler = (state, ex) => {
      this.setState({ connectionStatus: state == 'connected' ? null : state });
      if (state == 'error') Alert.alert('Connection Error', ex.message, [ { text: 'OK' } ], { cancelable: false });
    };
  }

  componentWillMount() {