This method does what engine.attach use to do but is now on the
instantiated server instance. This makes it possible to create engine.io
servers without yet attaching them to any active http server.
When creating a project which will server static files/pages alongside
engine.io on the same domain/process this makes it easier to separate
logic into files without having to pass around the http server.
This fixes an issue where multiple engine.io instances (on different
paths) would result in the closing of websocket connections for all of
the instances. This happened because each engine.io instance would
register an `upgrade` handler on the server. This handler would check
for a matching path and otherwise call `socket.end()` Since multiple
upgrade events would be triggered with different paths, the peer
handlers would close each other.
This patch resolves this behavior in the following way:
- When an instance upgrade handler encounters a path which it does not
recognize it creates a timeout for `destroyUpgradeTimeout`.
- At the end of the timeout, the socket is checked for writable state
and bytes written. If there has been not activity and the socket is
writable, then it will be ended.
This allows for peer socket handlers to keep the socket alive by sending
some data over it. This also mimics the core node behavior of closing
sockets on upgrade when no handler is specified. We consider not
handling an upgrade request similar to no handler. However, we cannot
immediately end the socket for the reasons noted above.
fixes#143