<commit_before>###
WebSocket Interface for the WebSocketRails client.
###
class WebSocketRails.WebSocketConnection

  constructor: (@url,@dispatcher) ->
    if @url.match(/^ws?:\/\//) or @url.match(/^wss?:\/\//)
        #URL scheme already defined, nothing to do
    else if window.location.protocol == 'http:'
        @url             = "ws://#{@url}"
    else
        @url             = "wss://#{@url}"
    
    @message_queue   = []
    @_conn           = new WebSocket(@url)
    @_conn.onmessage = @on_message
    @_conn.onclose   = @on_close
    @_conn.onerror   = @on_error

  trigger: (event) =>
    if @dispatcher.state != 'connected'
      @message_queue.push event
    else
      @_conn.send event.serialize()

  on_message: (event) =><commit_msg>Output a warning to console when using urls whit protocol scheme<commit_after>###
WebSocket Interface for the WebSocketRails client.
###
class WebSocketRails.WebSocketConnection

  constructor: (@url,@dispatcher) ->
    if @url.match(/^ws?:\/\//) or @url.match(/^wss?:\/\//)
        console.log "WARNING: Using connection urls with protocol specified is depricated"
    else if window.location.protocol == 'http:'
        @url             = "ws://#{@url}"
    else
        @url             = "wss://#{@url}"
    
    @message_queue   = []
    @_conn           = new WebSocket(@url)
    @_conn.onmessage = @on_message
    @_conn.onclose   = @on_close
    @_conn.onerror   = @on_error

  trigger: (event) =>
    if @dispatcher.state != 'connected'
      @message_queue.push event
    else
      @_conn.send event.serialize()

  on_message: (event) =>
{'fraction_non_alphanumeric': 0.15077881619937694, 'fraction_numerical': 0.0, 'mean_word_length': 2.4389721627408996, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '6817229', 'n_tokens_mistral': 522, 'n_tokens_neox': 516, 'n_words': 119}