Exemplo n.º 1
0
 private PluginInstance(
     [NotNull] IPluginEntry entry,
     [NotNull] IPluginBootstrapContext bootstrapContext,
     [NotNull] IPluginContext context
     )
 {
     Entry            = entry;
     BootstrapContext = bootstrapContext;
     Context          = context;
 }
Exemplo n.º 2
0
 private PluginInstance(
     IPluginEntry entry,
     IPluginBootstrapContext bootstrapContext,
     IPluginContext context
     )
 {
     Entry            = entry;
     BootstrapContext = bootstrapContext;
     Context          = context;
 }
        /// <inheritdoc />
        public override void OnBootstrap([ValidatedNotNull] IPluginBootstrapContext context)
        {
            context.Logging.Application.Info(
                $@"{nameof(ExampleClientPluginEntry)}.{nameof(OnBootstrap)} writing to the application log!");

            context.Logging.Plugin.Info(
                $@"{nameof(ExampleClientPluginEntry)}.{nameof(OnBootstrap)} writing to the plugin log!");

            mMutex = new Mutex(true, "testplugin", out var createdNew);
            if (!createdNew)
            {
                Environment.Exit(-2);
            }

            var exampleCommandLineOptions = context.CommandLine.ParseArguments <ExampleCommandLineOptions>();

            if (!exampleCommandLineOptions.ExampleFlag)
            {
                context.Logging.Plugin.Warn("Client wasn't started with the start-up flag!");
            }

            context.Logging.Plugin.Info("Registering packets...");
            if (!context.Network.TryRegisterPacketType <ExamplePluginClientPacket>())
            {
                context.Logging.Plugin.Error($"Failed to register {nameof(ExamplePluginClientPacket)} packet.");
                Environment.Exit(-3);
            }

            if (!context.Network.TryRegisterPacketType <ExamplePluginServerPacket>())
            {
                context.Logging.Plugin.Error($"Failed to register {nameof(ExamplePluginServerPacket)} packet.");
                Environment.Exit(-3);
            }

            context.Logging.Plugin.Info("Registering packet handlers...");
            if (!context.Network.TryRegisterPacketHandler <ExamplePluginServerPacketHandler, ExamplePluginServerPacket>(out _))
            {
                context.Logging.Plugin.Error($"Failed to register {nameof(ExamplePluginServerPacketHandler)} packet handler.");
                Environment.Exit(-4);
            }

            context.Logging.Plugin.Info(
                $@"{nameof(exampleCommandLineOptions.ExampleVariable)} = {exampleCommandLineOptions.ExampleVariable}");
        }
Exemplo n.º 4
0
        /// <inheritdoc/>
        public override void OnBootstrap(IPluginBootstrapContext context)
        {
            base.OnBootstrap(context);

            context.Logging.Application.Info(
                $@"{nameof(ExampleServerPluginEntry)}.{nameof(OnBootstrap)} writing to the application log!");

            context.Logging.Plugin.Info(
                $@"{nameof(ExampleServerPluginEntry)}.{nameof(OnBootstrap)} writing to the plugin log!");

            context.Logging.Plugin.Info("Registering packets...");
            if (!context.Network.TryRegisterPacketType <ExamplePluginClientPacket>())
            {
                context.Logging.Plugin.Error($"Failed to register {nameof(ExamplePluginClientPacket)} packet.");
                Environment.Exit(-3);
            }

            if (!context.Network.TryRegisterPacketType <ExamplePluginServerPacket>())
            {
                context.Logging.Plugin.Error($"Failed to register {nameof(ExamplePluginServerPacket)} packet.");
                Environment.Exit(-3);
            }

            context.Logging.Plugin.Info("Registering packet handlers...");
            if (!context.Network.TryRegisterPacketHandler <ExamplePluginClientPacketHandler, ExamplePluginClientPacket>(out _))
            {
                context.Logging.Plugin.Error($"Failed to register {nameof(ExamplePluginClientPacketHandler)} packet handler.");
                Environment.Exit(-4);
            }

            if (!context.Network.TryRegisterPacketPostHook <ExamplePluginLoginPostHook, LoginPacket>(out _))
            {
                context.Logging.Plugin.Error($"Failed to register {nameof(ExamplePluginLoginPostHook)} packet post-hook handler.");
                Environment.Exit(-4);
            }
        }
Exemplo n.º 5
0
        /// <inheritdoc />
        public override void OnBootstrap([NotNull, ValidatedNotNull] IPluginBootstrapContext context)
        {
            context.Logging.Application.Info(
                $@"{nameof(ExampleClientPluginEntry)}.{nameof(OnBootstrap)} writing to the application log!");

            context.Logging.Plugin.Info(
                $@"{nameof(ExampleClientPluginEntry)}.{nameof(OnBootstrap)} writing to the plugin log!");

            mMutex = new Mutex(true, "testplugin", out var createdNew);
            if (!createdNew)
            {
                Environment.Exit(-1);
            }

            var exampleCommandLineOptions = context.CommandLine.ParseArguments <ExampleCommandLineOptions>();

            if (!exampleCommandLineOptions.ExampleFlag)
            {
                context.Logging.Plugin.Warn("Client wasn't started with the start-up flag!");
            }

            context.Logging.Plugin.Info(
                $@"{nameof(exampleCommandLineOptions.ExampleVariable)} = {exampleCommandLineOptions.ExampleVariable}");
        }
Exemplo n.º 6
0
 /// <inheritdoc />
 public virtual void OnBootstrap(IPluginBootstrapContext context)
 {
 }