text: INIT_CHAT_RESPONSE = {
    ChatConnectionAttributes: {
      ConnectionId: "d51df30c-13ec-401d-8c9e-e5dceda82958",
      ParticipantCredentials: {
        ConnectionAuthenticationToken:
          "AQIDAHgaX8Kqw7kBwr5FwotbWcOGwqPDvmMdwpvDsCHChcKtw6jCuEXDrcKMUsOqwpLDgCvCo8O9ASHCtsKhNSPDsMKWw6bDu8O+OMKIBcOKw4jCvQAAAG4wbAYJKsKGSMKGw7cNAQcGwqBfMF0CAQAwWAYJKsKGSMKGw7cNAQcBMB4GCWDChkgBZQMEAS4wEQQMGmTCnRABdcKgYygxLgECARDCgCsofSvCg0fDoApvV8OVPl90KsKKw73DtT5Jw6gXcU7ClsKzwrfDikbCkUHCoThPw7MhLcOzPSAbecOdYzo6HMOLw7Q6wqLCqTpqw71bw7lZZVfDjMKiGCxlw4rClR8sJyTDjcOSWyIiwrTDrcKOCsKdwrpHOUBzwrTDusOucT0zwrTCg8Odw69BwogtG8O9QD7CkUfChigqwqrDiFTDgMOSfMOGwoDCgzsMeMOuw5BMw63DqsKuw4HDvMKsw4Aew6UHMMKbeMOaZ8KBFWzCgRbCqhN0AcKlw79Uw7Rmw47CucOnw5lvwpgkw7zDsQFoT8O0V8OHWsOzw6svwqttwokFw4ZOw6LCo8OLw5DCl8KmCjJhw6AfJTXDn17ChT4pUsO4w4MwMcKDwrtuw55SwqkUWSPCrcKXwodhwrJfw4rChAzCmxJhwo1hGMOPw6zDuBjCu8O+w4JU",
        Expiry: null
      },
      PreSignedConnectionUrl:
        "wss://a2sg9pz864ik5-ats.iot.us-west-2.amazonaws.com/mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAZQCD2SXGDWJMJO2K%2F20190220%2Fus-west-2%2Fiotdata%2Faws4_request&X-Amz-Date=20190220T234810Z&X-Amz-SignedHeaders=host&X-Amz-Signature=6677180a722fb2636cefc1658189a2e716f79697aa80dd39276d2b7436c482a7&X-Amz-Security-Token=FQoGZXIvYXdzED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OMKLwqzDusKPMMKGScKewrzDp1RFwonDi3AGLsORw57DjTfCiMKGBm7Ci8KwE8KXw7HChjnDoANHw6jCucKGXcK7w5bDpMOQwpfCqyvCuWQtwo0uHMOIwqJww5jDgMKewrsuPRPCmDMkSxYLOD4pw7/CpHxZw50uwq/Dp8K4w7jDjUjCsgzCkAAkw4PDvMO6YSLDp3l9w5bDlsONU8KBcsOKw77CjzTDlATCpynDoGbDncOWRMKkRV7DhGBvRcKtalDDjcKdJEA3woHDosOOw5rCg1/CrDI6L2pdwojCsMOfLXTDoizCujHCk2kowoA4w7w7CxnCnEXDucOpwqnDqMOFFTB+woXDtsKt";
  
  CHAT_ID = "07bac4ed-ce8d-4083-b328-960934fcb13e";
  
  class TestLogger {
    constructor(prefix) {
      this.prefix = prefix;
    }
  
    debug(data) {
      console.log(this.prefix, "debug", data);
    }
  
    info(data) {
      console.log(this.prefix, "info", data);
    }
  
    warn(data) {
      console.log(this.prefix, "warn", data);
    }
  
    error(data) {
      console.log(this.prefix, "error", data);
    }
  }
  
  class ChatControllerTest {
    setup() {
      var logger = new TestLogger("TEST_LOGGER_111");
      var self = this;
      var connectionDetails = {
        connectionToken: PTOKEN,
        ConnectionId: "5b15e516-1f3b-4bc0-b3c5-0a081d1fdfca",
        PreSignedConnectionUrl:
          "wss://a28nk5omtf35rr-ats.iot.us-west-2.amazonaws.com/mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAYSFVGR4NWN4R2TGX%2F20190102%2Fus-west-2%2Fiotdata%2Faws4_request&X-Amz-Date=20190102T194922Z&X-Amz-SignedHeaders=host&X-Amz-Signature=1ebbca0dc68eaf0cc07c68f857a8e6d95bfa69191a6488271ccb586b4774b226&X-Amz-Security-Token=FQoGZXIvYXdzEJX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaDLLxgk3D%2BjlwxiIv9yKEA8%2BNO8eu%2B5u20MxPPImJiA5yjNJyYIIBX8oI9z89fuqkCDGNZxUGJqCo%2BjjB5VUIpkwMD753wi%2BoILTJsbWCeKIjHfadkwee0ABQ3e%2FSgPcpTlKAYi1bYHd6oFjtD9Plc7P%2FV64VEyFTAu25avgzk24I4ma3qK%2BWIwDyWDO3t%2B5DOMa%2BLEF9rZdAnLpG%2FWHL%2FLYWNP1WJw84pajjQZeIJrkdbxwqQqm5Bueog5wBzNXNCGGpoKV5TkuUk0N8QWsEeEAVvUMGk2l7JHMldKeGzDUwude5DCE%2F%2Bk23DEhgrthxDTiwquvHX8cWLaAbkWn6Gfvok77OXdxoYsiOsVJlYgtxtSGTgVEsJgCPtC96QZCyzZ6k8a6AUOAul%2FF5YkUYl74nzDqiYC76IGN4Cng69IgLbvSQ7hNxZC9OWWo4HUdq2fzifUZz%2BfjB5LFaH%2FPU4K2NdfHuW4W9YGK1L1A78w9k%2Fc7GmgrN7WJIXu8TNjNFY7v6zZ4bGqVuK8GiHikqkhyw1Pgowqu04QU%3D"
      };
      var chatDetails = {
        initialContactId: CHAT_ID,
        contactId: CHAT_ID,
        participantId: PID,
        participantToken: PTOKEN
        //connectionDetails: connectionDetails
      };
      var config = {
        loggerConfig: {
          debug: true,
          //logger: logger,
          level: 1
        },
        region: "us-east-1"
      };
  
      connect.ChatSession.setGlobalConfig(config);
  
      setTimeout(() => {
        var config2 = config;
        config2.loggerConfig.logger = new TestLogger("TEST_LOGGER_222");
        config2.loggerConfig.level = 1;
        console.log("connect.SetGlobalConfig(config2);");
        connect.ChatSession.setGlobalConfig(config2);
      }, 60 * 1000);
  
      //var factory = new connectchatjs.ChatFactory();
      var input = {
        chatDetails: INIT_CHAT_RESPONSE,
        type: "CUSTOMER"
        // options: {
        //   region: "us-west-2"
        // }
      };
      self.chatController = connect.ChatSession.create(input);
      self.chatController.onConnectionBroken(data => {
        console.log("onNetworkLinkBreak");
        console.log(data);
        console.log("onNetworkLinkBreak");
      });
  
      self.chatController.onTyping(data => {
        console.log("onTyping");
        console.log(data);
        console.log("onTyping");
      });
  
      self.chatController.onMessage(data => {
        console.log("onMessage");
        console.log(data);
        console.log("onMessage");
      });
  
      self.chatController.onConnectionEstablished(data => {
        console.log("onNetworkLinkReestablished");
        console.log(data);
        console.log("onNetworkLinkReestablished");
      });
      //self.chatController.broadcaster.on("<<all>>", (e, d) => self.called(e, d));
    }
  
    called(eventType, data) {
      console.log("");
      console.log("ChatControllerTest callbacked: " + eventType + ": ");
      console.log(data);
      console.log("");
    }
  
    checkStuff() {
      console.log("Status is:");
      console.log(this.chatController.getConnectionStatus());
    }
  
    test1B() {
      var self = this;
      console.log("before disconnect");
      self.checkStuff();
      self.chatController
        .disconnectParticipant()
        .then(
          response => console.log("disconnect success", response),
          error => console.log("disconnect failed", error)
        );
      console.log("just after disconnect");
      self.checkStuff();
    }
  
    test1() {
      var self = this;
      console.log("before connect");
      self.checkStuff();
      self.chatController
        .connect()
        .then(function(response) {
          console.log("connect success");
          console.log("response is:");
          console.log(response);
          self.checkStuff();
        })
        .catch(function(error) {
          console.log("connect error");
          console.log("error is:");
          console.log(error);
          self.checkStuff();
        });
      console.log("just after connect");
      self.checkStuff();
    }
  
    sendEvent() {
      var self = this;
      var args = {
        eventType: "TYPING",
        messageIds: [],
        visibility: "ALL",
        persistence: "NON_PERSISTED"
      };
      args.metadata = { requestContext: "oye balle!!" };
      self.chatController
        .sendEvent(args)
        .then(function(response) {
          console.log("sendEvent response");
          console.log(response);
        })
        .catch(function(error) {
          console.log("sendEvent error");
          console.log(error);
          console.log("sendEvent error");
        });
      console.log("sendEvent called!!!");
    }
  
    getTranscript() {
      var self = this;
      var args = {};
      args.StartKey = {};
      args.StartKey.ItemId = "96a48038-c824-4ca0-b553-977da0df1df5";
      args.ScanDirection = "BACKWARD";
      args.SortKey = "ASCENDING";
      args.MaxResults = 5;
      var args2 = {};
      args2.metadata = { requestContext: "oye balle!!" };
      self.chatController
        .getTranscript(args2)
        .then(function(response) {
          console.log("transcript is");
          console.log(response);
        })
        .catch(function(error) {
          console.log("transcript error");
          console.log(error);
          console.log("transcript error");
        });
      console.log("getTranscript called!!!");
    }
  
    send() {
      var text = document.getElementById("myText").value;
      console.log("checking type!");
      console.log(typeof text);
      var self = this;
      var input = {
        message: text,
        type: "text/plain",
        metadata: { requestContext: "oye balle!!" }
      };
      self.chatController
        .sendMessage(input)
        .then(function(response) {
          console.log("sentSuccess: " + text);
          console.log(response);
        })
        .catch(function(error) {
          console.log("error");
          console.log(error);
          console.log("error");
        });
      console.log("sent: " + text);
    }
  
    reconnectTest() {
      var self = this;
      self.chatController.acpsClient
        .reconnectChat(PTOKEN)
        .then(function(response) {
          console.log("reconnectSuccess");
          console.log(response);
          console.log("reconnectSuccess");
        })
        .catch(function(error) {
          console.log("error");
          console.log(error);
          console.log("error");
        });
      console.log("recconnectCalled");
    }
  }
  
  testController = new ChatControllerTest();
  
  document.getElementById("button1").addEventListener("click", function() {
    testController.setup();
    console.log(testController.chatController);
  });
  
  document.getElementById("button2").addEventListener("click", function() {
    testController.test1();
  });
  
  document.getElementById("button3").addEventListener("click", function() {
    testController.test1B();
  });
  
  document.getElementById("sendButton").addEventListener("click", function() {
    testController.send();
  });
  
  document
    .getElementById("sendEventButton")
    .addEventListener("click", function() {
      testController.sendEvent();
    });
  
  document
    .getElementById("retrieveTranscript")
    .addEventListener("click", function() {
      testController.getTranscript();
    });
  
  /*
  
  class SoloChatConnectionIotHelperTest {
  
  
  
      setup() { 
          var self = this;
          var cId = "c8d1faa7-4818-4df1-b3f6-f11a71bf2391";
          var purl = "wss://a28nk5omtf35rr.iot.us-west-2.amazonaws.com/mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAYSFVGR4N6D7ANLEQ%2F20181116%2Fus-west-2%2Fiotdata%2Faws4_request&X-Amz-Date=20181116T002703Z&X-Amz-SignedHeaders=host&X-Amz-Signature=197ca4227a141d6d0ac5f8efed1620b115930a316d9ee95db6fc60181e8a6b9d&X-Amz-Security-Token=FQoGZXIvYXdzEBoaDEkVB0gSQ2BWvfAT6iKFA4dqWiitI8q84ZTk%2Bt9i8FOdEEZN1XfQTa5NTrAqWegZWGjlEw8vh6SsBSVU8kI9nLY7gQMXCJDnvSWzvaFdUkcL8amMXbKnQPBXRotzv7KjwZtSk6DW6vTrU9RGIEtAdxy%2FRA2Jc7sefFeWVlCgf6WekDNbGRSHN%2BEQp%2Fdeb32zpSqLYC1yoU6jqm%2B8QrMTbnaOkiQsEUkcGjfh5RZ%2BHpt4%2B%2Flc2IsEWPSMc7iUwEQTw1fJ6zxvJ5CEXk%2B%2B9KmJzDVDhKVSHe3n%2BrMJU25jUaNg4SEbLcdWbygWXBHfORzXr%2FHcwWqPV98F%2B83fVH8zxR%2F%2B6FqMvD6D67Lzn%2FQD9v%2Bf%2FBTOj%2Bhtg78det%2B43i0Lelc%2BN7BubuK65XU0ZHUk9XKOPokTZ6p%2FG007GvN0AfF8RyZdscxdUF3ZYTwdZmg4UB%2FemqRY1BJOxAa%2BB2ImpLfnPIwAykfuXTELvJccfGDOP7qEjtg4Er00245SxEeX0ZzRRX8nZLLWWGwOseoB4n0diDhVKNeduN8F";
          var connectionDetails = {
              "preSignedUrl": purl,
              "connectionId": cId
          }
          var connectionHelperProvider = CHAT_CONTROLLOR_FACTORY.createConnectionHelperProvider(connectionDetails);
          self.connectionHelper = connectionHelperProvider((eventType, data) => self.called(eventType, data));
      }
  
      called(eventType, data) {
          console.log("");
          console.log("SoloChatConnectionIotHelperTest callbacked: " + eventType + ": ");
          console.log(data);
          console.log("");
      }
  
      checkStuff() {
          console.log("Status is:");
          console.log(this.connectionHelper.getStatus());
      }
  
      test1B() {
          var self = this;
          console.log("before end");
          self.checkStuff();
          self.connectionHelper.end();
          console.log("just after end");
          self.checkStuff();
      }
  
      test1() {
          var self = this;
          console.log("before start");
          self.checkStuff();
          self.connectionHelper.start().
              then(function(response) {console.log("start success"); console.log("response is:"); console.log(response); self.checkStuff();}).
              catch(function(error) {console.log("start error"); console.log("error is:"); console.log(error); self.checkStuff();});
          console.log("just after start");
          self.checkStuff();
      }
  
  
  }
  
  testHelper = new SoloChatConnectionIotHelperTest();
  
  document.getElementById("button1").addEventListener("click", function() {testHelper.setup(); console.log(testHelper.connectionHelper)});
  
  document.getElementById("button2").addEventListener("click", function() {testHelper.test1()});
  
  document.getElementById("button3").addEventListener("click", function() {testHelper.test1B()});
  
  */
  
  /*
  class PahoIotConnectionTest {
  //
  this.preSignedUrl = args.preSignedUrl;
  this.connectionId = args.connectionId;
  this.callback = args.callback;
  //
  
  
  
      setup() {
          var cId = "7af56284-b815-4ed2-9251-0e969d88b52e";
          var purl = "wss://a28nk5omtf35rr.iot.us-west-2.amazonaws.com/mqtt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAYSFVGR4NRWG26FZO%2F20181115%2Fus-west-2%2Fiotdata%2Faws4_request&X-Amz-Date=20181115T073404Z&X-Amz-SignedHeaders=host&X-Amz-Signature=d6f3c9787ade426df800bace2869fc750c11d537c8359c3b210cbdaa5131b4e0&X-Amz-Security-Token=FQoGZXIvYXdzEAkaDKp7re%2BU2Irc1zZ6UyKEA8t%2BqXvfSXR3Apc0R94ONZemMwANWXXAeFeUqft9DwowzdlPypscMVU06V1supZnqt8hJb%2B6DTAiGSwyM7%2B7O%2BVgSpeflG3TbSJp5HQFdq1Dy%2FvQ7IAQ7GGRRmchOJpYIOFj3%2B6Htb0HaqIiAEQs%2FQf9jxwwSiMfC%2B2IHNhEKE1tY3xoD7xFyQkS2u8LT7GS63WMREhyjkGwRv%2F%2BtWc83UlML0DqOfhouOmGBJDXuwoTwp9itl9DTb78JbFGGhNcqRwQ1tIFt%2F3snd5dS03MQWNqSQGcvGa%2B%2BrdpK93c3XAIQjYRi5qUt8%2FmDhTDiKln80VzNZlTtJBGBOi6XgUufVAgw2CXjS%2BZ1m7Wac%2F2uqhaX0GgG88KoGquvDQ4MQ1SeX5ABEAgt3pp2%2BPebBcYFl9YD6qbFuR0WnGt11PSnR7cRz6qgWT8BezoZtUKQw5Ko4QCwTn8nHbTWEO3w5jW9CTmh6XNfimbmLJTHktq%2BgjMeVa6kHCkWe2eIcrYuxiDWrNUknAo7MK03wU%3D";
  
          self = this;
          self.purl = purl;
          self.cId = cId;
          //var cId = document.getElementById("iotConnId").value;
          //var purl = document.getElementById("iotPurl").value;
          var args = {
              preSignedUrl:purl,
              connectionId:cId,
              callback:function(eventType, data){self.called(eventType, data);},
              debug: true
          };
          self.paho = new PahoIotConnection(args);
          self.checkStuff();
      }
  
      called(eventType, data) {
          console.log("");
          console.log("PahoIotConnectionTest callbacked: " + eventType + ": ");
          console.log(data);
          console.log("");
      }
  
      test1D() {
          var self = this;
          console.log("just before disconnect");
          self.checkStuff();
          self.paho.disconnect();
          console.log("just after disconnect");
          self.checkStuff();
      }
  
      test1C() {
          var self = this;
          console.log("just before unsubscribe");
          self.checkStuff();
          self.paho.unsubscribe(self.cId, {}).
              then(function(response) {console.log("unsubscribe success: "); console.log(response); self.checkStuff(); setTimeout(self.test1D(), 3000);}).
              catch(function(error) {console.log("unsubscribe Failed: "); console.log(error); self.checkStuff();});
  
  
      }
  
      test1B() {
          var self = this;
          console.log("just before subscribe");
          self.checkStuff();
          self.paho.subscribe(self.cId, {"qos":1}).
              then(function(response) {console.log("subscribe success: "); console.log(response); self.checkStuff();}).
              catch(function(error) {console.log("subscribe Failed: "); console.log(error); self.checkStuff();});
          self.checkStuff();
      }
  
  
      test1() {
          self = this;
          this.paho.connect({
              useSSL: true,
              mqttVersion: 4,
              keepAliveInterval: 300,
              reconnect:true
          }).
              then(function(response) {console.log("connected: "); console.log(response); self.checkStuff(); setTimeout(function(){self.test1B();}, 3000)}).
              catch(function(error) {console.log("connectionFailed: "); console.log(error); self.checkStuff();});
          self.checkStuff();
          
      }
  
  
      checkStuff() {
          console.log("Status is:");
          console.log(this.paho.getStatus());
          console.log("Topics are:");
          console.log(this.paho.getSubscribedTopics());
      }
  
  }
  
  
  testPaho = new PahoIotConnectionTest();
  document.getElementById("button1").addEventListener("click", function() {testPaho.setup(); testPaho.test1()});
  
  document.getElementById("button2").addEventListener("click", function() {testPaho.test1C()});
  */
  
  /*
  participantToken = "AQIDAHhGwqfCvMO4XkBJFVZswpXDnR85wq7DlwI7wo8qwqHDj8KcARNkw6wpwqbDvMOYw4oBw5HClcOKwqjCnWHChsKJFRc/w6bDo8OqIsOFAAAAbjBsBgkqwoZIwobDtw0BBwbCoF8wXQIBADBYBgkqwoZIwobDtw0BBwEwHgYJYMKGSAFlAwQBLjARBAx0w70LwpTDi8KuKsKoCcOfw6/CvQIBEMKAK8K6wrxgR8Kvw73Dj03Ck8Kcwr5Jw48Kw5vDhWfDmHZpwp8/QlvDrcOTw4dlwp/Cv0bClUDCv8OmIBHCsGh6ccKZw686OkhbD8KaKsKNwrPDiAUNDsKTwqYSwoDCvcKCw5zChcKjw48od8KmXnpIwpx1JUN8VMKsAcOBw7dMfcO6S8OEwrPDnMKzNgYZw6VucnbCi8OjO1TDksKZMRfCm8KQJMK9w41lwp7CicKDw5DCpkLCphYcwojDm3rClxnCjcKUHEBRw59HfcOvw7EXMWLCt17DknwPwoU+a0xgfcKvG8O7TsObJ8KJw7s6fmjCiMKjBikOFcKxI2rCncKtZcKfwoAlLcKcw7ZOwrzCsRHDqsOSYMKvSgEqE8KcVMKtZmvDgV4uwqbCusOxw4XCi8O1LA/CgsKrFHbDj8Kuw5fDl1B/G0RIVcOpf8KgYTnDlcKnIcOpRQE=";
  
  client = ACPS_CLIENT_FACTORY.getClient("PROD");
  function testThis() {
  client.sendTextMessage(participantToken, "textMessageSend").
      then(function(r) {console.log("response"); console.log(r);}).
      catch(function(e){console.log("error"); console.log(e);});
  
  }
  
  document.getElementById("button1").addEventListener("click", function() {testThis()});
  */
  