Giter Club home page Giter Club logo

webrcon-csharp's Introduction

WebRcon-CSharp is the official .Net/Mono/C# plugin to work with WebRcon.

  1. Requirements
  2. Installation
  3. Usage
  4. FAQ
  5. License
  6. About

Requirements

In order to use this plugin, you first need to:

  • A valid WebRcon ckey
  • .NET 3.5 framework / Mono 3.0 or superior installed

Installation

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.

Usage

Initialization

string cKey = "0M6EQVX8PI"; //Your cKey should go here
WebConsole console = new WebConsole(cKey);
console.Initialize();
console.onLinked += () => {
    //Your code
};
  1. First, create a "WebConsole" object and assign your cKey.
  2. Call "Initialize" method.
  3. Once the communication is stablished and the plugin is linked to the server, the "onLinked" event will fire.

Logging messages to WebConsole

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");

Registering Commands

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.

Closing the connection

console.Close();

It is recommended to manually close the connection at the end of the execution of your application.

Events

  • "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.

FAQ

What is WebRcon?

Visit WebRcon Website to obtain all needed info.

What is the cKey?

The cKey is the generated code that will link your application to a WebConsole.

Can I use this plugin on Unity?

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.

License

This project is licensed under the MIT License - see the LICENSE file for details

About

Created by SickDev.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.