Ejemplo n.º 1
0
        public bool Init()
        {
            if (mIsInitCalled)
            {
                return(false);
            }
            mIsInitCalled = true;

            MyBaseThing.RegisterEvent(eEngineEvents.IncomingMessage, HandleMessage);
            if (TheThing.GetSafePropertyString(MyBaseThing, "VisitorCount") == "")
            {
                VisitorCount = 0;
            }
            MyNodePrintsName = $"NodePrints{TheThing.GetSafeThingGuid(MyBaseThing, "NodePrints")}";
            TheBaseEngine.WaitForStorageReadiness(OnStorageReady, true);
            MyBaseThing.SetPublishThrottle(15000);
            TheCommCore.RegisterRelayEvents(null, null, sinkNewConnection);

            if (MyVisitorLog == null)
            {
                MyVisitorLog = new TheVisitorLog(MyBaseThing);
            }
            TheQueuedSenderRegistry.RegisterHealthTimer(GetSystemInfo);
            TheCDEngines.MyNMIService.RegisterEvent("NMI_MY_LOCATION", (sender2, para) =>
            {
                var t = para as TheNMILocationInfo;
                if (t != null)
                {
                    var NewEntry = new TheVisitorLogData {
                        cdeN = t.cdeN, latitude = t.Latitude, longitude = t.Longitude, ip = t.ClientInfo?.UserID.ToString(), LastVisit = DateTimeOffset.Now, Description = t.ClientInfo != null && t.ClientInfo.UserID != Guid.Empty ? TheUserManager.GetUserFullName(t.ClientInfo.UserID) : "Unknown user"
                    };
                    MyVisitorLog.LogVisitor(NewEntry);
                    myGoogleMap?.SetUXProperty(Guid.Empty, $"AddMarker={TheCommonUtils.SerializeObjectToJSONString(NewEntry)}");
                }
            });
            TheCommCore.MyHttpService.RegisterHttpInterceptorB4("/cdemeshinfo.aspx", sinkRequestMeshInfo);
            MyBaseEngine.ProcessInitialized();
            MyBaseEngine.SetEngineReadiness(true, null);
            MyBaseEngine.SetStatusLevel(1);
            mIsInitialized = true;
            return(true);
        }