internal void ZitiRouterEvent(ZitiRouterEvent evt) { OnZitiRouterEvent?.Invoke(this, evt); }
private void ziti_event_cb(IntPtr ziti_context, IntPtr ziti_event_t) { int type = Native.NativeHelperFunctions.ziti_event_type_from_pointer(ziti_event_t); switch (type) { case ZitiEventFlags.ZitiContextEvent: NativeContext = ziti_context; WrappedContext = new ZitiContext(ziti_context); Native.ziti_context_event ziti_context_event = Marshal.PtrToStructure <Native.ziti_context_event>(ziti_event_t); var vptr = Native.API.ziti_get_controller_version(ziti_context); ziti_version v = Marshal.PtrToStructure <ziti_version>(vptr); IntPtr ptr = Native.API.ziti_get_controller(ziti_context); string name = Marshal.PtrToStringUTF8(ptr); ZitiContextEvent evt = new ZitiContextEvent() { Name = name, Status = (ZitiStatus)ziti_context_event.ctrl_status, StatusError = Marshal.PtrToStringUTF8(ziti_context_event.err), Version = v, Identity = this, }; InitOpts.ZitiContextEvent(evt); lock (this) { Monitor.Pulse(this); isInitialized = true; } break; case ZitiEventFlags.ZitiRouterEvent: Native.ziti_router_event ziti_router_event = Marshal.PtrToStructure <Native.ziti_router_event>(ziti_event_t); ZitiRouterEvent routerEvent = new ZitiRouterEvent() { Name = Marshal.PtrToStringUTF8(ziti_router_event.name), Type = (RouterEventType)ziti_router_event.status, Version = Marshal.PtrToStringUTF8(ziti_router_event.version), }; InitOpts.ZitiRouterEvent(routerEvent); break; case ZitiEventFlags.ZitiServiceEvent: Native.ziti_service_event ziti_service_event = Marshal.PtrToStructure <Native.ziti_service_event>(ziti_event_t); ZitiServiceEvent serviceEvent = new ZitiServiceEvent() { nativeRemovedList = ziti_service_event.removed, nativeChangedList = ziti_service_event.changed, nativeAddedList = ziti_service_event.added, ziti_ctx = ziti_context, Context = this.ApplicationContext, id = this, }; if (isStreaming) { foreach (var removed in serviceEvent.Removed()) { services.Remove(removed.Id); } foreach (var changed in serviceEvent.Changed()) { services[changed.Id] = changed; } foreach (var added in serviceEvent.Added()) { services[added.Id] = added; } streamLock.Release(); } InitOpts.ZitiServiceEvent(serviceEvent); break; default: Logger.Warn("UNEXPECTED ZitiEventFlags [{0}]! Please report.", type); break; } }