Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: gorshing on June 27, 2003, 05:36 PM

Title: Staying Connected
Post by: gorshing on June 27, 2003, 05:36 PM
I am going to develop a bot using C++ (MS 6.0) I have some source code from a VB bot that I am going to go off of.

But the main problem with the VB bot is that it loses it's connection frequently.  I would like to be able to stay connected ... is there something that I could send battle.net to let it know that I am still alive?

I will use WSAAsyncSelect (I believe that is correct) for FD_READ, FD_ACCEPT, and FD_CLOSE ... so when I get disconnected I will connect again ... but I would like to try and prevent, as much as possible, getting disconnected.

Any ideas, or older posts that I have missed?

Thanks for any help,
Title: Re:Staying Connected
Post by: Camel on June 27, 2003, 05:49 PM
Send an 0x0 packet (no data, just FF 00 04 00) every once in a while. At the very least, send one back whenever battle.net sends you one.
Title: Re:Staying Connected
Post by: iago on June 27, 2003, 06:28 PM
every 60 seconds is ideal.

One way to do this in c++ is to have a timer thread, but that's a little nasty (you have to do some thread synchronization).  Or in your main loop you can check if the current time in seconds is divisible by 60 and if it is send out that packet.
Title: Re:Staying Connected
Post by: Camel on June 27, 2003, 08:12 PM
Couldn't one just use select() and have it give up after 60 seconds?
Title: Re:Staying Connected
Post by: Brolly on June 29, 2003, 09:07 PM
Or you can use SetTimer() and handle WM_TIMER.
Title: Re:Staying Connected
Post by: Camel on June 29, 2003, 11:06 PM
Quote from: Brolly on June 29, 2003, 09:07 PM
Or you can use SetTimer() and handle WM_TIMER.

Would that be more simple?
Title: Re:Staying Connected
Post by: Brolly on June 30, 2003, 10:48 AM
Yes. Every X seconds, a WM_TIMER message will be sent. You might not be able to do this in VB, however.
Title: Re:Staying Connected
Post by: DarkMinion on June 30, 2003, 12:50 PM
You can use timers in VB, it's just different.
Title: Re:Staying Connected
Post by: Camel on June 30, 2003, 06:38 PM
Quote from: DarkMinion on June 30, 2003, 12:50 PMYou can use timers in VB, it's just different.
Well, basicly it's just a CallBack function (which is a paint to debug as the entire VB process will be terminated if the callback function fails to return). VB timer objects are rather useful when efficiency is not the goal.
Title: Re:Staying Connected
Post by: DarkMinion on June 30, 2003, 07:04 PM
Yes, I went through that particular hang once when I used VB.
Title: Re:Staying Connected
Post by: gorshing on July 01, 2003, 07:29 AM
Thanks for all the replies ... that's what I figured for a binary bot.

My apologies for not specifing that I am working with a chat bot.

Sorry once again,