         return true
 
 
+class ServerDeprecatedWrapper
+    constructor: (server_options) ->
+        @listeners = {}
+        @options = {}
+        if server_options
+            utils.objectExtend(@options, server_options)
+
+    addListener: (event, listener) ->
+        if @installed
+            throw Error('Don\'t add listeners after "installHandler" was run.')
+        if not (event of @listeners)
+            @listeners[event] = []
+        @listeners[event].push(listener)
+
+    installHandlers: (http_server, user_options) ->
+        @installed = true
+        options = {}
+        utils.objectExtend(options, @options)
+        if user_options
+            utils.objectExtend(options, user_options)
+        srv = new ServerInstance(options)
+        for event of @listeners
+            for listener in @listeners[event]
+                srv.addListener(event, listener)
+        srv.installHandlers(http_server)
+        return srv
+
+ServerDeprecatedWrapper.prototype.on = \
+    ServerDeprecatedWrapper.prototype.addListener
+
+
 sockjs_version = ->
     try
         package = fs.readFileSync(__dirname + '/../package.json', 'utf-8')
     catch x
     return if package then JSON.parse(package).version else null
 
-exports.Server = Server
+exports.Server = ServerDeprecatedWrapper
+exports.ServerInstance = ServerInstance

utils.objectExtend(App.prototype, trans_htmlfile.app)


class Server extends events.EventEmitter
    constructor: (user_options) ->
        @options =
            prefix: ''

                return false
            ee.addListener(event, new_handler)

        path_regexp = new RegExp('^' + @options.prefix  + '([/].+|[/]?)$')
        handler = (req, res, extra) =>
            if not req.url.match(path_regexp)
                return false
