# Plugin-side implementation

**CgiRemoteControl.exe** is the execution trigger that starts plugin processing from the command line; the actual processing is implemented and executed on the plugin side. Therefore, on the plugin side, implement the **IEventListener** interface to handle events.

- Set the **EventsToSubscribe** property to include **EventId.PluginControlCommand**. If this is not set, **OnPluginControl** will not be called.
- The **OnPluginControl** method processes the received command string and returns a status code indicating success or failure.
- If **OnPluginControl** returns a non‑zero value, subsequent calls to **OnPluginControl** in other plugins will not occur.

This design ensures that when the `--PlugInControl` argument is specified, the plugin is invoked correctly.

<p class="callout info">See the <span style="color: rgb(230, 126, 35);">[Sample Implementation Guide](https://doc316en.candera.eu/books/cgiremotecontrol/page/sample-implementation-guide)</span> for step-by-step instructions and the complete source code.</p>

##### Implementation Example:

```c++
public class SamplePlugin : IEventListener
{
    // Subscribe to specific events by implementing this property
    public virtual EventId EventsToSubscribe
    {
        get { return EventId.PluginControlCommand; }
    }

    // Implement the OnPluginControl method to handle the plugin command
    public int OnPluginControl(string command)
    {
        //this.LoggerSvc.Info(DateTime.Now + ":test log start"); // Info: 1/17/2025 11:13:01 AM:test log start
        //Console.WriteLine($"Received command: {command}");     // Received command: BuildHost 4711
        // Perform actions based on the command
        return 0; // Return an appropriate status code
    }
}
```