Code Monkey home page Code Monkey logo

rconsharp's Introduction

rconsharp

rconsharp is a Valve RCON protocol implementation for .NET written in C# as a Portable Class Library (PCL).

Usage

Clone this repository and build the solution to get the assemblies. At this point of time, you can either reference the PCL and provide your custom implementation of INetworkSocket or reference the other projects (right now only .Net 4.5 is implemented). Due to the shared structure of PCLs it's not possible to have a common implementation of a network socket and this is the reason why a concrete class to handle network communication will be needed for each platform you need to target.

NuGet packages

Instead of manually downloading binaries or building the sources, you can simply add it by installing the NuGet package. Just search for rconsharp from the package manager or type PM> Install-Package RconSharp in NuGet command line.

There's also a package contining an implementation of INetworkSocket interface. Search for rconsharp.socket or type PM> Install-Package RconSharp.Socket in NuGet command line. Currently only .net 4.5 is supported and as soon as i can find some spare time i will provide implementations for other platforms.

Quick example

This is a very basic snippet that allows you to forward commands to a Rcon enabled remote server. (In order to run this example, you also need the package RconSharp.Socket to be installed from NuGet)

// create an instance of the socket. In this case i've used the .Net 4.5 object defined in the project
INetworkSocket socket = new RconSocket();

// create the RconMessenger instance and inject the socket
RconMessenger messenger = new RconMessenger(socket);

// initiate the connection with the remote server
bool isConnected = await messenger.ConnectAsync("remotehost", 12345);

// try to authenticate with your supersecretpassword (... obviously this is my hackerproof key, you shoul use yours)
bool authenticated = await messenger.AuthenticateAsync("supersecretpassword");
if (authenticated)
{
  // if we fall here, we're good to go! from this point on the connection is authenticated and you can send commands 
  // to the server
  var response = await messenger.ExecuteCommandAsync("/help");
}

Note: rconsharp is designed to work with the async/await paradigm. Nothing to be afraid of but remember you have to mark the encapsulating method with the async keyword and you have to await the awaitable methods in order to get the results. Refer to the official documentation if you wish to learn more on the subject.

Dependencies

All the dependencies within this project are referenced as NuGet packages and will be restored upon first build (if you have this option enabled NuGet settings). Following is the list of referenced packages:

  • Microsoft Async
  • Microsoft BCL Build Components
  • Microsoft BCL Portability Pack
  • Moq (just for the tests)

Client example

The minecraft client example has been moved to his own repository. You can find it here

Licensing

This code is distributed under the very permissive MIT License but, if you use it, you might consider referring to the repository. Please refer to LICENSE file for the complete license description.

rconsharp's People

Contributors

stefanodriussi avatar wgraham17 avatar

Watchers

 avatar

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.