Simple usage example:

var rcon = new Connection("127.0.0.1", 25505);

// Called when a connection is established.
rcon.Connected += () =>
{
    Console.WriteLine("Connected to the server...");
    // Authentication is needed in order to use administrative requests.
    rcon.Authenticate("PASSWORD"); 
};

// Called when authentication succeeds.
rcon.Authenticated += () =>
{
    // Connection is now authenticated, we can start sending administrative requests.
    conn.Request("admin.eventsEnabled", true);
    Console.WriteLine("Authenticated.");
};

// Called when the server sends a request.
rcon.RequestPacket += (packet) =>
{
    Console.WriteLine("Request [" + String.Join("], [", packet.Words) + "]");
    rcon.Respond(packet, "OK"); // Generic response
};

// Called when the server responds to a request.
rcon.ResponsePacket += (packet) =>
{
    Console.WriteLine("Response to #" +
        packet.Sequence + " [" + String.Join("], [", packet.Words) + "]");
};

/// Many other events here, like:
/// Connecting
/// ConnectFailed
/// Reconnecting 
/// Disconnected
/// Error
/// StateChanged

// Connect to the server.
rcon.Connect();

Console.ReadKey();

Last edited Jun 29, 2012 at 9:13 PM by WoLfulus, version 6

Comments

No comments yet.