       throw 'invalid params for unbind custom event unbind(str, fn)'
     (evts = @_events?[event])?.splice? evts.indexOf(fct), 1
     @
+  unbindAll: -> @_events = {}
   trigger: (event, args...) ->
     return false if false is @_events?[event]?.every? (fct) => false isnt fct.apply @, args
     @

    sio.on 'connecting', (t) ->
      console.log 'connecting', t
    sio.on 'reconnect', (type, attempts) =>
      @connected = yes
      # todo: do not need to re-login for reconnection
      location.reload() if confirm 'Reconneced Reload Required!\n Click OK to retry.'
      @trigger 'reconnected', type, attempts
    # bind fns to client.io ! JS 1.8.5
    console.log 'wait for connect msg'

  connect: (isretry) -> # start connect, auto start when init
    url = @base + @id
    console.log 'connect', url
    sio = @socket ? (@socket = @io.connect url) # connect to server
    unless @connected then _timeout = @wait 3000, -> # 3s
      _timeout = null
      if isretry
