Code Monkey home page Code Monkey logo

corercon's Introduction

Unmaintained

I am no longer maintaining CoreRCON. I will still review and accept pull requests if somebody takes the time to make one, but since I am not involved in any of the games this library was written for, I am also not fit for the job. If you are interested in maintaining this repo, please contact me.

Still, give it a fair shot, it might still work for you!

CoreRCON

CoreRCON is an implementation of the RCON protocol on .NET Core. It currently supports connecting to a server, sending commands and receiving their output, and receiving logs from logaddress.

Supports:

Installation

CoreRCON is available on NuGet, and can be installed with:

Install-Package CoreRCON

Quick Start

Connect to an RCON server and send a command

The IP address supplied here is the server you wish to connect to.

using CoreRCON;
using CoreRCON.Parsers.Standard;
// ...

// Connect to a server
var rcon = new RCON(IPAddress.Parse("10.0.0.1"), 27015, "secret-password");

// Send "status"
Status status = await rcon.SendCommandAsync<Status>("status");

Console.WriteLine($"Connected to: {status.Hostname}");

Listen for chat messages on the server

This assumes you have been added to the server's logaddress list. You do not need to make an rcon connection to receive logs from a server.

The port specified must be open (check your router settings) and unused. Pass a value of 0 to use the first-available port. Access log.ResolvedPort to see which port it chose.

Finally, pass an array (or list of params) of IPEndPoints to express which servers you would like to receive logs from. This is because any server can send your server logs if they know which port you are listening on, as it's just UDP.

using CoreRCON;
using CoreRCON.Parsers.Standard;
// ...

// Listen on port 50000 for log packets coming from 10.0.0.1:27015
var log = new LogReceiver(50000, new IPEndPoint(IPAddress.Parse("10.0.0.1"), 27015));
log.Listen<ChatMessage>(chat =>
{
	Console.WriteLine($"Chat message: {chat.Player.Name} said {chat.Message} on channel {chat.Channel}");
});

Troubleshooting

Can't install via NuGet

"Could not install package 'CoreRCON X.X.X'. You are trying to install this package into a project that targets '.NETFramework,Version=vy.y.y', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author."

If you are seeing an error similar to this, try changing your project's targeted .NET Framework version [#11]. If you are using Visual Studio 2015, the minimum resolvable framework version is 4.7. Visual Studio 2017 has improved support for .NET Core packages, allowing CoreRCON to resolve for versions as low as 4.6.1.

Changelog

Version 3.0.0

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.