BeBot - An Anarchy Online and Age Of Conan chat automaton
Archive => Anarchy Online Archive => BeBot 0.4 support => Topic started by: DocJones on June 19, 2008, 01:50:34 pm
-
Heyas,
i am currently working on a MSN interconnection for BeBot to allow MSN Messenger chatting into the game. However, i am a little stuck with message handling:
I have a receive function that gets called via cron["1sec"] every second, but within that second, on the inbound buffer i can have more than one message. Unfortunately the messages are not seperated, so i cant handle them properly.
Is there a possibility to start a background thread from within the bot in any kind to allow a better polling of the connection? Or even a *gasp* event driven mechanism (to react only if there are data on the tcp socket)?
Any help appreciated.
/M
-
You could hook directly into the callback() function inside Main.php. Or the cron() function inside Bot.php. Both those functions are called whenever the chat class polls for new input from the chat-server.
-
Currently i set up cron every second, but there are often more than one data packet arriving within one second. How does the callback function work?
-
callback() is called every time the socket connection to the ao chat server is polled, which is several times each second from my experience.
-
are you unable to split what you get up?
-
No, not really. i found the basic msn module on the net and revamping it to fit into the structure. However, i am not that skilled php programmer and the code is quite undocumented. I think i need to get a debug environment to get a better understanding. Any hints on that?
regards
-
Heyas,
on a quick sidenote: my debugging output of a 1sec cron looks like this:
....
Invbot [2008-06-23 09:29:07] [MSN] [CRON] RX
Invbot [2008-06-23 09:29:07] [MSN] [CRON] TX
Invbot [2008-06-23 09:29:09] [MSN] [CRON] RX
Invbot [2008-06-23 09:29:09] [MSN] [CRON] TX
Invbot [2008-06-23 09:29:11] [MSN] [CRON] RX
Invbot [2008-06-23 09:29:11] [MSN] [CRON] TX
Invbot [2008-06-23 09:29:13] [MSN] [CRON] RX
Invbot [2008-06-23 09:29:13] [MSN] [CRON] TX
Invbot [2008-06-23 09:29:15] [MSN] [CRON] RX
Invbot [2008-06-23 09:29:15] [MSN] [CRON] TX
Invbot [2008-06-23 09:29:17] [MSN] [CRON] RX
Invbot [2008-06-23 09:29:17] [MSN] [CRON] TX
Invbot [2008-06-23 09:29:19] [MSN] [CRON] RX
Invbot [2008-06-23 09:29:19] [MSN] [CRON] TX
Invbot [2008-06-23 09:29:21] [MSN] [CRON] RX
Invbot [2008-06-23 09:29:21] [MSN] [CRON] TX
Invbot [2008-06-23 09:29:23] [MSN] [CRON] RX
Invbot [2008-06-23 09:29:23] [MSN] [CRON] TX
...
Anyone noticed, that the 1sec handler is acutally being called every 2 sec?
regards
/K
-
Yes, can look like that. 1sec cron time only guarantees that at least one second is between two executions of the cron job, it doesn't guarantee any minimum interval if some other load is there.
-
ooookkkkeeii,
got it working so far. Only problem is: i want to listen the Msn-class to all "/tell" commands (currently "/tell <botname> !msn <text>" works). I tried to set up $commands["tell"][] = &$msn; to hook upon all tells, but that doesn't work. The bot simply send me a "/tell <botname> !help" back. Any help, please?
regards
-
The tells pseudo-channel should be what you are looking for. It hands all incoming tells that aren't commands over to registering modules. There you have to do any access checks yourself.
$commands["tells"][] = &$msn;