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


Go Back   FPSadmin.com > BattleField > Bad Company 2 > BC2: Remote Admin Tool Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-06-2010, 04:20 PM
Timi Timi is offline
Junior Member
 
Join Date: Apr 2010
Posts: 17
Rep Power: 0
Timi is on a distinguished road
.NET RCON Library

Hello, I'm Tim from AwpaholicA and TimScripts. I have just finished writing and documenting the beginnings of a .NET library for BFBC2's RCON.

Inside are binaries for the .NET library and a sample console application. Also included is the source code for both.

Although the code isn't pretty since I pretty much just moved the Python version to this platform, it appears to work very well. Included with the library is an RCON class for connecting to RCON.

More information, such as the current features to what's going to be done, can be found in the included documentation in the form of a PDF file.

If there are any feature requests or bugs, I'd love to hear about them.

Lastest version: 1.0.0.1

Last edited by Timi; 05-01-2010 at 12:38 PM.
Reply With Quote
  #2  
Old 04-10-2010, 08:52 PM
Kalms Kalms is offline
Senior Member
 
Join Date: Feb 2010
Posts: 262
Rep Power: 9
Kalms is on a distinguished road
Cool stuff, however you should update it to work with a receive buffer (see R9 CommandConsole.py) -- the current version will have trouble with large responses.
Reply With Quote
  #3  
Old 04-11-2010, 09:28 AM
Timi Timi is offline
Junior Member
 
Join Date: Apr 2010
Posts: 17
Rep Power: 0
Timi is on a distinguished road
I upped the buffer size on the version I am working on, but I'm finishing a few other updates before I release again.

For those that want to update it themselves, there is also a fix for a bug where the server will terminate communications with the socket after a period of inactivity.

First, change lines 139 and 140 from this:
Code:
            Dim packet2(4096) As Byte
            Dim bytesReceived As Integer = RCONSocket.Receive(packet2, 4096, SocketFlags.None)
To this:
Code:
            Dim packet2(16384) As Byte
            Dim bytesReceived As Integer = RCONSocket.Receive(packet2, 16384, SocketFlags.None)
Then, add the following lines below line 103 in Public Sub connect()
Code:
                    Dim level As SocketOptionLevel = IIf(Environment.OSVersion.Version.Major > 5, SocketOptionLevel.Socket, SocketOptionLevel.Tcp)
                    tempSocket.SetSocketOption(level, SocketOptionName.KeepAlive, 1)
                    tempSocket.IOControl(IOControlCode.KeepAliveValues, New Byte() {1, 0, 0, 0, 1, 0, 0, 0, 224, 147, 4, 0}, Nothing)
                    tempSocket.SendBufferSize = 16384
                    tempSocket.ReceiveBufferSize = 16384
The specific portion of the code should now look like:
Code:
                    If tempSocket.Connected Then
                        Dim level As SocketOptionLevel = IIf(Environment.OSVersion.Version.Major > 5, SocketOptionLevel.Socket, SocketOptionLevel.Tcp)
                        tempSocket.SetSocketOption(level, SocketOptionName.KeepAlive, 1)
                        tempSocket.IOControl(IOControlCode.KeepAliveValues, New Byte() {1, 0, 0, 0, 1, 0, 0, 0, 224, 147, 4, 0}, Nothing)
                        tempSocket.SendBufferSize = 16384
                        tempSocket.ReceiveBufferSize = 16384

                        RCONSocket = tempSocket
                        Exit For
                    End If
The additional code above will send keep-alives to the server every 5 minutes so that the client isn't disconnected. The buffer size for the socket, in addition to the receive for the first fix, is increased to the new recommendation.

Edit: I must have been half-asleep when I did this since not all of the data would be received at once. I'll be sure to implement something along the lines of the python example code. Thanks for the heads-up.

Last edited by Timi; 04-11-2010 at 02:54 PM.
Reply With Quote
  #4  
Old 04-13-2010, 05:35 PM
Trekkan Trekkan is offline
Junior Member
 
Join Date: Apr 2010
Posts: 1
Rep Power: 0
Trekkan is on a distinguished road
Looks good, I'm going to check this out. =)
Reply With Quote
  #5  
Old 04-27-2010, 07:38 AM
Fritz.fx Fritz.fx is offline
Junior Member
 
Join Date: Apr 2010
Posts: 3
Rep Power: 0
Fritz.fx is on a distinguished road
WOW, I'm surprised this thread has received so little replies.
I don't know about the rest of the world, but to me, this is the front row ticket to creating your own server Admin tool.


Two weeks ago, I didn't really even know what .NET was. Thanks to Timi, I'm on my way to creating a customised Admin tool for our clan::
With tid-bits

With in-game admin commands available. kills/deaths/all events uploaded to a MySQL server on the fly.

Double thumbs up for Timi
Reply With Quote
  #6  
Old 05-01-2010, 12:35 PM
Timi Timi is offline
Junior Member
 
Join Date: Apr 2010
Posts: 17
Rep Power: 0
Timi is on a distinguished road
After a crazy long time of no updates, I finally have another

This update addresses an issue where the socket would disconnect after some inactivity.
The socket will now support the larger packet requirements that started with R8/R9.
The final main issue that was resolved is that the send method would remain locked when the authenticated event was triggered; now, the send method is unlocked before the event is sent.

Developing with this library is now much easier, too.
Sequences are now tracked so you'll know what command the server is responding to.

There are now events for the server's events, such as the chat and kill events. This way, the packetReceive event will no longer need to handle those events. However, older code using this event will no longer work, so it'll have to be moved over. If this is too inconvenient, the source code can be easily changed to have the packetReceive event still be triggered after the regular event is triggered.

Connecting is now faster due to optimizations in the way the socket connects.

There is also a PlayerList class and a Player class added to the library. More information on this can be found in the documentation. Note, however, that this feature has not been tested since the server I test on is empty. Should there be a bug and you want a quick fix, you can comment-out plist in the Private Variables region and the playerList property in the Properties region.

Now that I can't think of anything else to say:
http://timscripts.com/system/files/BFBC2RCON.NET_.zip
Reply With Quote
  #7  
Old 05-01-2010, 04:41 PM
Timi Timi is offline
Junior Member
 
Join Date: Apr 2010
Posts: 17
Rep Power: 0
Timi is on a distinguished road
Double post to ensure an edit is not overlooked:

I finally had a chance to test everything out, and I've reuploaded and fixed some bugs. I also made some changes to the console application to make it less annoying.

The link is still the same:
http://timscripts.com/system/files/BFBC2RCON.NET_.zip
Reply With Quote
  #8  
Old 06-03-2010, 05:22 AM
dnLL dnLL is offline
Junior Member
 
Join Date: May 2010
Posts: 16
Rep Power: 0
dnLL is on a distinguished road
It doesnt support C#
Reply With Quote
  #9  
Old 06-08-2010, 04:49 PM
Timi Timi is offline
Junior Member
 
Join Date: Apr 2010
Posts: 17
Rep Power: 0
Timi is on a distinguished road
Quote:
Originally Posted by dnLL View Post
It doesnt support C#
In which way? I haven't tested it out thoroughly on C#, but there's nothing about it that should work in C# applications.

I briefly checked it in a C# application, and I was able to add the reference to the project and use one of the events successfully.

First, I created a console program. After adding a reference to the dll, I tested the noPass event, which triggers when there's no password stored when the connect method is used.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BC2RCON;

namespace bc2cstest1
{
    class Program
    { 
        static void Main(string[] args)
        {
            RCON RCONObj = new RCON("server", 1337, "");
            RCONObj.noPass += new RCON.dnoPass(RCONObj_noPassEvent);

            Console.WriteLine("testing c# capability");
            RCONObj.Connect();

            Console.ReadLine();
        }
        static void RCONObj_noPassEvent()
        {
            Console.WriteLine("no pass");
        }
        
    }
}
This code displayed the "no pass" message to the console.
Reply With Quote
  #10  
Old 06-18-2010, 02:11 PM
dnLL dnLL is offline
Junior Member
 
Join Date: May 2010
Posts: 16
Rep Power: 0
dnLL is on a distinguished road
Works =]

Last edited by dnLL; 06-18-2010 at 02:30 PM.
Reply With Quote
  #11  
Old 06-19-2010, 06:54 PM
dnLL dnLL is offline
Junior Member
 
Join Date: May 2010
Posts: 16
Rep Power: 0
dnLL is on a distinguished road
Can someone please give an example of using of playerList and Player classes ? I cant figure it out how
Reply With Quote
  #12  
Old 06-30-2010, 10:43 AM
Timi Timi is offline
Junior Member
 
Join Date: Apr 2010
Posts: 17
Rep Power: 0
Timi is on a distinguished road
Here's an update that adds the new events and adds more functionality to the PlayerList and Player Classes
http://timscripts.com/system/files/BFBC2RCON.NET__0.zip

Information on the changes and all functionality in the library can be found in the included documentation.

Edit: Re-released new version fixing bugs. Above link still works.

Last edited by Timi; 07-01-2010 at 09:03 AM.
Reply With Quote
  #13  
Old 10-28-2011, 04:44 AM
RickardP RickardP is offline
Junior Member
 
Join Date: Oct 2011
Posts: 1
Rep Power: 0
RickardP is on a distinguished road
Do you going to update your rcon library for Battlefield 3?

I trying to use it and it works the little i have done so far with BF3 but i gess there is stuff to change.

And can someone tell me a exemple how i list all players from the PlayerList ?

getPlayers is some parameters i dont understand..
Reply With Quote
Reply

Bookmarks

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 07:34 AM.


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