Click or drag to resize
How Do I Implement ZApp Plugin
Zet Universe

[This is preliminary documentation and is subject to change.]

Both IZetApp and IZetProcessor require you to implement a common underlying interface, IPlugin, that is used to define all plugins for Zet Universe.

Plugin Description Properties

  • Define values for descriptional properties, such as Id (it should be a unique Guid), Publisher, Title, and Version.

Implement IPlugin Interface

  1. Declare private member ZetHost and implement public IHost property:

    internal IZetHost ZetHost;
    
    public IHost Host
    {
        get; set;
    }
  2. Method invokation support is not currently required, thus implement Invoke() method as follows:

    public object Invoke(string message, params object[] args)
    {
        return null;
    }
  3. Implement OnConnection() method, retrieve IHost, cast it to IZetHost, retrieve IAppSettings, and use these values to continue initializing your plugin:

    public bool OnConnection(ConnectMode mode)
    {
        if (this.Host == null) throw new NotImplementedException("Host is not available");
    
        this.ZetHost = this.Host as IZetHost;
    
        if (this.ZetHost == null) throw new PlatformNotSupportedException("This build of Zet Universe platform is not supported. Host doesn't implement ZU.Plugins.IZetHost interface");
    
        IAppSettings settings = this.ZetHost.AppManager.GetAppSettings(this).Result;
    
        // Continue plugin initialization using a separate Initialize() method
        this.Initialize(settings, this.ZetHost.SIM, this.ZetHost.AppManager);
    
        return true;
    }
  4. Plugin disconnection is not currently supported; yet, this will be available in the future releases. For now, implement OnDisconnection() method:

    public bool OnDisconnection(DisconnectMode mode)
    {
        return true;
    }

IAppSettings and Accounts

  1. Declare private member _settings, and implement GetCurrentAppSettings() method:

    internal ZU.Configuration.Settings.IAppSettings _settings;
    
    public IAppSettings GetCurrentAppSettings()
    {
        return this._settings;
    }
  2. Decide if it needs support for more than one account, and define AreMultipleAccountsAllowed property accordingly.

  3. Use the IAppSettings.Accounts list as the one used for your IZetApp.Accounts property:

    public List<IAppAccount> Accounts
    {
        get
        {
            return this._settings.Accounts;
        }
        set
        {
            this._settings.Accounts = value;
        }
    }