How to use the network.localUserId function in network

To help you get started, we’ve selected a few network 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 samuelmaddock / metastream / packages / metastream-app / src / analytics / index.ts View on Github external
const state = store.getState()
  const { allowTracking } = state.settings
  if (!allowTracking) {
    console.debug('Analytics tracking disabled')
    window.ga = () => {}
    return
  }

  const clientId = process.env.GA_CLIENT_ID
  if (!clientId) return

  // https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
  const analytics = new Analytics(clientId, {
    appName: PRODUCT_NAME,
    appVersion: VERSION,
    clientId: localUserId()
  })

  window.ga = (...args: any[]) => {
    try {
      analytics.send(...args)
    } catch (e) {
      console.error(e)
    } finally {
      // Reset session heartbeat timer; keeps number of heartbeats sent only to
      // what's absolutely necessary to keep the session alive.
      startSession(store)
    }
  }
}
github samuelmaddock / metastream / packages / metastream-app / src / components / lobby / VideoPlayer.tsx View on Github external
private get isPermittedBySafeBrowse() {
    const media = this.props.current

    // Always playback self-requested media
    if (media && media.ownerId === localUserId()) {
      return true
    }

    return this.props.safeBrowseEnabled
      ? this.state.permitURLOnce || SafeBrowse.getInstance().isPermittedURL(this.mediaUrl)
      : true
  }
github samuelmaddock / metastream / packages / metastream-app / src / containers / LobbyPage.tsx View on Github external
private onLoadScreen() {
    this.host = this.props.match.params.lobbyId === localUserId()
    this.props.dispatch(initLobby({ host: this.host }))

    if (!this.host || this.supportsNetworking) {
      this.setupLobby()
    }
  }
github samuelmaddock / metastream / packages / metastream-app / src / lobby / actions / users.ts View on Github external
const userJoined = (userId: string): RpcThunk => (dispatch, getState, context) => {
  if (localUserId() === userId) {
    return
  }

  const username = getUserName(getState(), userId)
  const content = translateEscaped('userJoined', { userId, username })
  dispatch(addChat({ content, html: true, timestamp: Date.now() }))
}
export const multi_userJoined = rpc('userJoined', RpcRealm.Multicast, userJoined)
github samuelmaddock / metastream / packages / metastream-app / src / containers / LobbyPage.tsx View on Github external
constructor(props: PrivateProps) {
    super(props)
    this.host = props.match.params.lobbyId === localUserId()
  }