 
 class FlintSenderManager extends EventEmitter
 
-    constructor: (@appId, @device, @useHeartbeat) ->
-        if not @appId or not @device
+    constructor: (@options) ->
+        if not @options
             throw 'FlintSenderManager constructor error'
 
-        @urlBase = @device.urlBase
+        @appId = @options.appId
+
+        @urlBase = @options.urlBase
         @serviceUrl = @urlBase + '/apps/' + @appId
-        @host = @device.host
-
-        if @useHeartbeat is undefined
+        @host = @options.host
+
+        if @options.useHeartbeat is undefined
             @useHeartbeat = true
+        else
+            @useHeartbeat = @options.useHeartbeat
 
         @appState = {}
         @additionalData = {}

            'Accept': 'application/xml; charset=utf8'
        @_getState @serviceUrl, headers, (result, state) =>
            callback? result, state, @additionalData
            @emit 'appstate', result, state, @additionalData

    _getState: (url, headers, callback) ->
        @_request 'GET', url, headers, null, (statusCode, responseText) =>

                    else # join failed, stop failed
                        @_onStop 'appstop', false, callback

    disconnect: (callback) ->
        @_stopHeartbeat()
        @_stop 'disconnect', @serviceUrl, callback

    _onStop: (type, result, callback) ->
        callback? type, result

    _stop: (stopType, url, callback) ->
        if not @token
