Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: FiReGoD on April 08, 2003, 05:42 AM

Title: Auto-Reconnect on Disconnection
Post by: FiReGoD on April 08, 2003, 05:42 AM
i was wondering how you can do a auto-reconnect function, i was thinking a timer and every so often seconds it checks to see if you are connected, but that would just waste memory,

i am using visual basics, and running csb(cleanslatebot).
Title: Re:Auto-Reconnect on Disconnection
Post by: haZe on April 08, 2003, 06:07 AM
On the BnetDisconnected event, call csb.connect I believe.
Title: Re:Auto-Reconnect on Disconnection
Post by: FiReGoD on April 08, 2003, 10:05 AM
i know but what if you disconnect from the mnuDisconnect() function

then when you do that it will just reconnect
Title: Re:Auto-Reconnect on Disconnection
Post by: Yoni on April 08, 2003, 10:53 AM
Have a boolean variable like "ShouldBeConnected".
This variable will be True when the bot should be connected, or False when the bot should be disconnected.

Then, when you disconnect intentionally (i.e. from the mnuDisconnect function):
ShouldBeConnected = False
CSB.Close ' or whatever the function name is

And in the BnetDisconnected event:
If ShouldBeConnected Then CSB.Connect
Title: Re:Auto-Reconnect on Disconnection
Post by: CupHead on April 08, 2003, 12:15 PM
If you're using CleanSlateBot1.Disconnect as part of your mnuDisconnect sub, then reconnecting on disconnect will be fine.  The .Disconnect method intentionally does not raise the BnetDisconnected, RealmDisconnected, and/or BNLSDisconnected events.
Title: Re:Auto-Reconnect on Disconnection
Post by: Banana fanna fo fanna on April 08, 2003, 07:17 PM
I've never heard of visual basics.
Title: Re:Auto-Reconnect on Disconnection
Post by: Smurfling on April 10, 2003, 09:24 AM
This code i am using for VB.Net:

Handles the CleanSlateBot.OCX Event Disconnected:
Private Sub BNET_Disconnected(ByVal sender As Object, ByVal e As System.EventArgs) Handles csb.BnetDisconnected

AddChat(Col.FromKnownColor(Color_Text_Error), "Disconnected from Battle.Net.")
csb.Connect()

End Sub


Handles your mnuDisconnect() Event:
Private Sub mnuDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuDisconnect.Click

If csb.Connected = True Then csb.Disconnect()

End Sub


csb = CleanSlateBot.ocx