<commit_before>import Ember from 'ember';

export default Ember.Controller.extend({
  iceServers: null,

  init () {
    if (window.Realtime) {
      this.connectRealtime();
    } else {
      Ember.run.later(this, this.connectRealtime);
    }
  },

  connectRealtime () {
    const realtime = new window.Realtime({
      host: 'https://realtime.mypurecloud.com:443',
      guest: true,
      orgId: 397,
      jidRouting: true,
      jidResource: 'webrtc-troubleshoot'
    });

    realtime.on('rtcIceServers', servers => {
      console.log(JSON.stringify(servers));
      this.set('iceServers', servers);
      this.set('realtimeConnected', true);
    });

    realtime.onConnect(() => {

    });

    realtime.connect();
    this.set('realtime', realtime);
  },

  actions: {
    openTroubleshoot () {
      alert('troubleshooting!'); // eslint-disable-line
    }
  }
});
<commit_msg>Started adding dynamic realtime.js environments<commit_after>import Ember from 'ember';

export default Ember.Controller.extend({
  iceServers: null,

  realtimeEnvironments: {
    'apps.mypurecloud.com':    { host: 'https://realtime.mypurecloud.com:443', orgId: 397 },
    'apps.mypurecloud.com.au': { host: 'https://realtime.mypurecloud.com.au:443', orgId: 397 }, // Need an orgId for this one
    'apps.mypurecloud.de ':    { host: 'https://realtime.mypurecloud.de :443', orgId: 397 }, // Need an orgId for this one
    'apps.mypurecloud.ie ':    { host: 'https://realtime.mypurecloud.ie :443', orgId: 397 }, // Need an orgId for this one
    'apps.mypurecloud.jp':     { host: 'https://realtime.mypurecloud.jp:443', orgId: 397 }, // Need an orgId for this one
    'apps.inintca.com':        { host: 'https://realtime.inintca.com:443', orgId: 397 }, // Need an orgId for this one
    'apps.inindca.com':        { host: 'https://realtime.inindca.com:443', orgId: 397 }, // Need an orgId for this one
    'localhost':               { host: 'https://realtime.mypurecloud.com:443', orgId: 397 },
  },

  init () {
    if (window.Realtime) {
      this.connectRealtime();
    } else {
      Ember.run.later(this, this.connectRealtime);
    }
  },

  connectRealtime () {
    const realtime = this.getRealtimeInstance();

    realtime.on('rtcIceServers', servers => {
      console.log(JSON.stringify(servers));
      this.set('iceServers', servers);
      this.set('realtimeConnected', true);
    });

    realtime.onConnect(() => {

    });

    realtime.connect();
    this.set('realtime', realtime);
  },

  getRealtimeInstance () {
    const windowHost = window.location.host;
    // const windowHost = "apps.mypurecloud.com";
    // const windowHost = "apps.mypurecloud.com.au";
    // const windowHost = "apps.mypurecloud.de ";
    // const windowHost = "apps.mypurecloud.ie ";
    // const windowHost = "apps.mypurecloud.jp";
    // const windowHost = "apps.inintca.com";
    // const windowHost = "apps.inindca.com";
    let host;
    let orgId;
    let environments = this.get('realtimeEnvironments');
    if (windowHost.indexOf('localhost') > -1) {
      host = environments.localhost.host;
      orgId = environments.localhost.orgId;
    } else {
      host = environments[windowHost].host;
      orgId = environments[windowHost].orgId;
    }

    const realtime = new window.Realtime({
      host: host,
      guest: true,
      orgId: orgId,
      jidRouting: true,
      jidResource: 'webrtc-troubleshoot'
    });

    return realtime;
  },

  actions: {
    openTroubleshoot () {
      alert('troubleshooting!'); // eslint-disable-line
    }
  }
});

{'fraction_non_alphanumeric': 0.15573078006195437, 'fraction_numerical': 0.015488594762038862, 'mean_word_length': 2.807073954983923, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 9, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4031307', 'n_tokens_mistral': 1260, 'n_tokens_neox': 1172, 'n_words': 224}