Random Reconnect Timeout

Other plugins for extending OpenKore's functionality. This forum is only for posting new plugins and commenting on existing plugins. For support, use the Support forum.

Moderator: Moderators

Message
Author
d3fc0n
Noob
Noob
Posts: 9
Joined: 04 Apr 2008, 13:34

Random Reconnect Timeout

#1 Post by d3fc0n »

working on SVN 2.0.5

random reconnect timeout every connecting to master server.

config.txt
reconnect <base time>
reconnectSeed <seeding time>
randreconn.pl

Code: Select all

#########################################################################
# This software is open source, licensed under the GNU General Public
# License, version 2.
# Basically, this means that you're allowed to modify and distribute
# this software. However, if you distribute modified versions, you MUST
# also distribute the source code.
# See http://www.gnu.org/licenses/gpl.html for the full license.
#########################################################################
# Random Reconnnect Timeout (fixed)
# d3fc0n 1/12/2007
#########################################################################

package randtimeout;

use strict;
use Plugins;
use Globals qw(%config $masterServer %timeout);
use Log qw(message);

Plugins::register('randtimeout', 'Random Reconnnect Timeout', \&on_unload);

my $hooks = Plugins::addHooks(
		['Network::connectTo', \&onConnectTo]
	);

sub on_unload {
	Plugins::delHooks($hooks);
}

sub onConnectTo {
	my (undef, $args) = @_;

	if ($args->{host} eq $masterServer->{ip} && $args->{port} eq $masterServer->{port}) {

		if ($config{'reconnect'}) {
			my $reconnect = $config{'reconnect'} + int(rand $config{'reconnectSeed'});
			message("[randtimeout] Reconnect timeout has been change to $reconnect second.\n", "system");
			$timeout{'reconnect'}{'timeout'} = $reconnect;
		}
	}
}

return 1;
sorry for my eng. i'm just another thailander.

einbroch
Human
Human
Posts: 21
Joined: 14 May 2011, 10:22
Noob?: Yes

Re: Random Reconnect Timeout

#2 Post by einbroch »

This is cool :)

Post Reply