Esempio n. 1
0
        public MainPage()
        {
            this.InitializeComponent();

            //load configs
            ActiveCfg = VirtNodeConfig.GetDefaultConfig();

            //load keys (untile a full configuration ui is implemented, just load these 2 for now)
            ActiveCfg.NodeKey    = _storageService.LoadSettingString("NodeKey");
            ActiveCfg.NodeSecret = _storageService.LoadSettingString("SecretKey");

            //add me as entry assembly
            TypeCache.AddEntryAssembly(typeof(Program));

            //init nodelibrary confs
            NodeConfig conf = new NodeConfig()
            {
                uuid                           = "UniversalSampleNode2", //ActiveCfg.Uuid,
                Name                           = "Universal Sample Node",
                YpServer                       = ActiveCfg.ApiServer,
                YpchannelPort                  = ActiveCfg.YpchannelPort,
                SecureYpc                      = ActiveCfg.YpchannelSecure,
                CertificationServerName        = ActiveCfg.CertificationServerName,
                FrontendServer                 = ActiveCfg.FrontendServer,
                CanSolveGraphs                 = ActiveCfg.CanSolveGraphs,
                Pairing_CompletionInstructions = "Close the browser tab and switch back to the App",
                Pairing_NoUUIDAuthentication   = true, //same machine authentication, no uuid authentiation required

                EnableNodeDiscovery = false,
#if false
                NodeDiscovery_YPCPort_Start = 5000,
                NodeDiscovery_YPCPort_End   = 65000,
#else
                NodeDiscovery_YPCPort_Start = 0,
                NodeDiscovery_YPCPort_End   = 0,
#endif
            };

            //prepare pairing module
            pairmodule = new Yodiwo.Node.Pairing.CommonDevicePairingPolling();

            //create node
            node = new Yodiwo.NodeLibrary.Node(conf,
                                               Helper.GatherThings(),
                                               pairmodule,
                                               NodeDataLoad, NodeDataSave
                                               );

            //register node  cbs
            //node.OnChangedState += ChangedState;
            node.OnTransportConnected    += OnConnected;
            node.OnTransportDisconnected += OnDisconnected;
            node.OnTransportError        += OnTransportError;
            node.OnNodePaired            += OnPaired;
            node.OnUnexpectedMessage      = HandleUnknownMessage;
            node.OnThingActivated        += Node_OnThingActivated;
            node.OnThingDeactivated      += Node_OnThingDeactivated;

            //register port events
            RegisterThings();
        }