Skip to content

Commit

Permalink
Handle socket closed events.
Browse files Browse the repository at this point in the history
  • Loading branch information
pekim committed Jan 5, 2012
1 parent f926f77 commit 886cfd5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/connection2.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ class Connection extends EventEmitter
@socket.connect(@config.options.port, @config.server)
@socket.on('error', @socketError)
@socket.on('connect', @socketConnect)
@socket.on('close', @socketClose)
@socket.on('end', @socketClose)

@messageIo = new MessageIO(@socket, @config.options.packetSize, @debug)
@messageIo.on('packet', (packet) =>
Expand Down Expand Up @@ -218,6 +220,10 @@ class Connection extends EventEmitter
@debug.log("connected to #{@config.server}:#{@config.options.port}")
@dispatchEvent('socketConnect')

socketClose: =>
@debug.log("connection to #{@config.server}:#{@config.options.port} closed")
@transitionTo(@STATE.FINAL)

sendPreLogin: ->
payload = new PreloginPayload()
@messageIo.sendMessage(TYPE.PRELOGIN, payload.data)
Expand Down

0 comments on commit 886cfd5

Please sign in to comment.