     $.ajax
       url: @endpoint
       type: 'DELETE'
+    console.log "Chat Terminated"
 
-    @killed = true
-    @started = false
-    @startPending = false
+    @state = stateEnum.KILLED
     console.log "Chat Client Chat Terminated"

window.InteractionWebTools.Chat ||= {}

class InteractionWebTools.Chat.Client
  constructor: ->
    @started = false
    @queuedMessages = []
    @endpoint = '/interaction_web_tools/events'
    @chatUI = $('#chat-ui')

        if (event.type == 'participantStateChanged' &&
            event.state == 'disconnected' &&
            event.participant_type == 'WebUser')
          @state = stateEnum.KILLED

      setTimeout () =>
        @pollMessages()
      , 1000 if @state == stateEnum.STARTED || @state == stateEnum.START_PENDING

  sendMessage: (message) ->
    return unless message
    return @queueMessage(message) unless @state == stateEnum.STARTED

    $.post @endpoint, { event: { content: message } }, (data) =>
      @renderMessages data.events
