<commit_before>const SockJS = require('sockjs')
const http = require('http')

const Emitter = require('../../kite/emitter')
const Session = require('./session')

class Server extends Emitter {
  constructor(options) {
    super()

    this.sockjs = SockJS.createServer()
    this.server = http.createServer()
    this.options = options ? options : {}

    this.sockjs.on('connection', connection => {
      return this.emit('connection', new Session(connection))
    })

    this.sockjs.installHandlers(this.server, { prefix: options.prefix || '' })
    this.server.listen(options.port, options.hostname || '0.0.0.0')
  }

  getAddress() {
    return this.server._connectionKey
  }

  close() {
    if (this.server != null) {
      return this.server.close()
    }
  }
}

Server.scheme = 'http'
Server.secureScheme = 'https'

export default Server
<commit_msg>Server/SockJs: port is not optional, _connectionKey is deprecated<commit_after>const SockJS = require('sockjs')
const http = require('http')

const Emitter = require('../../kite/emitter')
const Session = require('./session')

class Server extends Emitter {
  constructor(options) {
    super()

    this.sockjs = SockJS.createServer()
    this.server = http.createServer()
    this.options = options ? options : {}
    this.options.hostname = this.options.hostname || '0.0.0.0'
    if (!this.options.port) throw new Error('port is required!')


    this.sockjs.on('connection', connection => {
      return this.emit('connection', new Session(connection))
    })

    this.sockjs.installHandlers(this.server, { prefix: options.prefix || '' })

    this.server.listen(options.port, options.hostname)
  }

  getAddress() {
    return `${this.options.hostname}:${this.options.port}`
  }

  close() {
    if (this.server != null) {
      return this.server.close()
    }
  }
}

Server.scheme = 'http'
Server.secureScheme = 'https'

export default Server

{'fraction_non_alphanumeric': 0.15340314136125655, 'fraction_numerical': 0.004188481675392671, 'mean_word_length': 3.4545454545454546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3486003', 'n_tokens_mistral': 598, 'n_tokens_neox': 584, 'n_words': 122}