Game server admin's helping the community setup and maintain great dedicated game servers.
----Home----Submit News ----Forum--------Guides----

Go Back > BattleField > BattleField 3 > BF3 Remote Admin Tool Support

Thread Tools Display Modes
Old 02-02-2012, 08:21 PM
Kalms Kalms is offline
Senior Member
Join Date: Feb 2010
Posts: 262
Rep Power: 9
Kalms is on a distinguished road
FrostbiteRcon library in C++

Hi all,

I spent most of yesterday evening and today making an RCON interface library and a little console app in C++.

You can find the sourcecode here:

The project/solution files will load in Visual Studio 2010.

It is not very well tested, it has no comments, it has no usage instructions, the test programs are very quirky... but I'll give a rundown here.

There are a couple of different projects in there:
  • RconLibrary is the interface library itself.
  • ...Test are short test programs.
  • Console is a simple command console.
  • ServerVersionQuery is a program that issues "version" requests to a bunch of servers in parallel.

Now if we break down RconLibrary a bit, you find three classes for managing packets - see RconPacket.h:
  1. 'Words' is how you will likely pass around commands outside of RconLibrary.
  2. When it's time to transmit a command to the server, it is converted to a TextRconPacket. This is essentially the Words, along with sequence info.
  3. The final step before transmission is converting it to a BinaryRconPacket. This is a contigous stream of bytes, ready to be sent over the wire.
When receiving a packet from the server, it will go through the classes in the reverse order until it is presented as plain Words outside of the library.

Then there are three different communications modules:
  • SynchronousServerConnection is single-threaded, simple to use, but will only allow the user to send commands to the server. It is not suitable for receiving events.
  • AsynchronousServerConnection is single-threaded. It can be used to send commands and receive events. It requires the user to call an update() method with regular intervals.
  • ThreadedServerConnection is multithreaded. It can be used to send commands and receive events.
The callback design for the async & threaded communications modules is still quite messy. I hope to work a bit more on it in the future.

Other stuff you'll find in there:
ServerConnectionTrafficBase is used to snoop on what's going on in the communications modules. It is intended for debugging.
Mutex is a win32 CrititcalSection packaged in an OS-agnostic interface.
ThreadBase is a win32 Thread packaged in an OS-agnostic interface.

And yes, there are some known problems. Some pretty bad, other minor.
- the ServerVersionQuery program will occasionally complain about a pure function call when querying real servers. This makes me think that there is an obscure race condition hiding in the thread usage, or the Mutex or the WaitableThreadBase classes. Don't trust them just yet.
- The threading usage in the Console example program is a bit ugly (there's probably a race condition or two hiding in there).

Last edited by Kalms; 02-04-2012 at 06:35 PM.
Reply With Quote
Old 02-03-2012, 02:28 PM
Kalms Kalms is offline
Senior Member
Join Date: Feb 2010
Posts: 262
Rep Power: 9
Kalms is on a distinguished road
Bugfixes & improvements.

I had the client/server origin flag flipped. Correcting that, the server is no longer echoing my requests when events are enabled.

The mechanism for receiveing a server-event and responding to it works properly for a threaded connection now (you get an object which can live for arbitrarily long, and you do responseObject->sendResponse(...) on the object to respond to that particular event).

The async connections lack an equally convenient mechanism for responding to events.
Reply With Quote
Old 02-04-2012, 04:51 PM
PapaCharlie9's Avatar
PapaCharlie9 PapaCharlie9 is offline
Senior Member
Join Date: Jan 2011
Posts: 155
Rep Power: 8
PapaCharlie9 is on a distinguished road
Forum admin, please sticky for truth!

Thanks for the example code. I'm sure this will save a lot of people time and frustration in the future.
Reply With Quote
Old 08-06-2013, 11:06 AM
DeadHunter DeadHunter is offline
Junior Member
Join Date: Aug 2013
Posts: 1
Rep Power: 0
DeadHunter is on a distinguished road
I used the RconPacket and TextPacket Class.
For the connection i used boost.
This program is just for a few ingame commands and it runs on unix (Boost and C++11 needed).

If someone needs an example, feel free to use it.

Last edited by DeadHunter; 08-11-2013 at 11:47 AM.
Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -4. The time now is 09:47 AM.

Powered by: vBulletin Copyright ©2000, Jelsoft Enterprises Ltd.