@@ -29,6 +29,7 @@ import path from 'path';
2929import expressHandlebars from 'express-handlebars' ;
3030import ipRegex from 'ip-regex' ;
3131import * as SegfaultHandler from 'segfault-handler' ;
32+ import { Device as DeviceSchema } from 'gateway-addon/lib/schema' ;
3233
3334// Keep these imports here to prevent circular dependencies
3435import './plugin/outlet-proxy' ;
@@ -45,6 +46,7 @@ import Router from './router';
4546import RulesController from './controllers/rules_controller' ;
4647import sleep from './sleep' ;
4748import Things from './models/things' ;
49+ import { ThingDescription } from './models/thing' ;
4850import TunnelService from './tunnel-service' ;
4951import { WiFiSetupApp , isWiFiConfigured } from './wifi-setup' ;
5052import { AddressInfo } from 'net' ;
@@ -400,3 +402,18 @@ TunnelService.switchToHttps = () => {
400402 }
401403 } ) ;
402404} ;
405+
406+ AddonManager . on ( Constants . THING_ADDED , ( thing : ThingDescription ) => {
407+ Things . handleNewThing ( thing ) ;
408+ } ) ;
409+
410+ AddonManager . on ( Constants . THING_REMOVED , ( thing : DeviceSchema ) => {
411+ Things . handleThingRemoved ( thing ) ;
412+ } ) ;
413+
414+ AddonManager . on (
415+ Constants . CONNECTED ,
416+ ( { device, connected } : { device : DeviceSchema ; connected : boolean } ) => {
417+ Things . handleConnected ( device . id , connected ) ;
418+ }
419+ ) ;
0 commit comments