WebRcon-CSharp is the official .Net/Mono/C# plugin to work with WebRcon.
In order to use this plugin, you first need to:
- A valid WebRcon ckey
- .NET 3.5 framework / Mono 3.0 or superior installed
To use this plugin, you can either download the precompiled libraries or compile them from source code yourself.
Once compiled, add references "WebRCon.Core.dll" and "CommandSystem.dll" to your C# project.
string cKey = "0M6EQVX8PI"; //Your cKey should go here
WebConsole console = new WebConsole(cKey);
console.Initialize();
console.onLinked += () => {
//Your code
};
- First, create a "WebConsole" object and assign your cKey.
- Call "Initialize" method.
- Once the communication is stablished and the plugin is linked to the server, the "onLinked" event will fire.
console.defaultTab.Log("Hello World!");
To show messages on the web console, call the "Log" method on any "Tab" object. If no other tabs have been created explicitely, you can use the "defaultTab".
To create and send message to another tab, simply call the method "CreateTab".
Tab newTab = console.CreateTab("Tab name");
newTab.Log("This message is sent to the new tab");
public static bool IsNumberEven(int number) {
return (number % 2) == 0
}
...
Command command = new FuncCommand<int, bool>(IsNumberEven);
console.commandsManager.Add(command);
Once a command is registered, it can be called from the WebConsole.
Commands management is implemented by the CommandSystem, which allows to parse strings into ready-to-use commands. The CommandSystem already contains a full in-depth guide of how it works, so feel free to read it and familiarize yourself with it.
console.Close();
It is recommended to manually close the connection at the end of the execution of your application.
- "onLinked" : Called when the connection status becomes linked.
- "onUnlinked" : Called when the connection status becomes unlinked.
- "onDisconnected" : Called when the connection status becomes disconnected. Returns the reason as an ErrorCode.
- "onError" : Called from the server when something is wrong. Returns the specific ErrorCode.
- "onExceptionThrown" : Called when an asynchronous operation throws an exception. The exception can come from either plugin source code or from the execution of a custom command.
- "onCommand" : Raised when a command is called from the WebConsole. Use it to manually manage the execution of commands. If no delegate is assigned to this event, the CommandSystem will execute the command automatically.
Visit WebRcon Website to obtain all needed info.
The cKey is the generated code that will link your application to a WebConsole.
You can find the Unity plugin for WebRcon on Github.
How do I register additional assemblies to use with CommandSystem?
WebConsole console = new WebConsole(cKey, "AssemblyName1", "AssemblyName2");
When creating a new "WebConsole" object, you can specify assemblies to register via its constructor.
This project is licensed under the MIT License - see the LICENSE file for details
Created by SickDev.