Proper initialization of adaptors

This commit is contained in:
Andrew Stewart 2013-10-23 11:10:52 -07:00
parent 541d70b66d
commit bf4d42970e
3 changed files with 5 additions and 1 deletions

View File

@ -29,5 +29,5 @@ module.exports = class Connection
@adaptor.disconnect @adaptor.disconnect
requireAdaptor: (adaptorName) -> requireAdaptor: (adaptorName) ->
console.log "dynamic load adaptor" Logger.info "dynamic load adaptor"
@robot.requireAdaptor(adaptorName, self) @robot.requireAdaptor(adaptorName, self)

View File

@ -20,6 +20,7 @@ class Loopback
connect: -> connect: ->
console.log "Connecting to adaptor '#{@name}'..." console.log "Connecting to adaptor '#{@name}'..."
self
disconnect: -> disconnect: ->
console.log "Disconnecting from adaptor '#{@name}'..." console.log "Disconnecting from adaptor '#{@name}'..."

View File

@ -72,6 +72,9 @@ module.exports = class Robot
require("cylon-#{adaptorName}").register(self) unless self.adaptors[adaptorName]? require("cylon-#{adaptorName}").register(self) unless self.adaptors[adaptorName]?
require(self.adaptors[adaptorName]).adaptor(name: adaptorName).connect(connection: connection) require(self.adaptors[adaptorName]).adaptor(name: adaptorName).connect(connection: connection)
requireAdaptor: (adaptorName, connection) ->
self.requireAdaptor(adaptorName, connection)
registerAdaptor: (moduleName, adaptorName) -> registerAdaptor: (moduleName, adaptorName) ->
return if self.adaptors[adaptorName]? return if self.adaptors[adaptorName]?
self.adaptors[adaptorName] = moduleName self.adaptors[adaptorName] = moduleName