Buffered Send
The Buffered Send aka SendQ system was a new feature in IRCBot v3. It assures that any asynchronous I/O does not cause problems on your IRC servers and also ensures the bot does not send so much data as to flood itself off the network.
The SendQ in IRCBot v3 had 2 levels: low priority spam/bulk data and high priority interactive data, this worked pretty well.
It was completely revamped and rewritten for IRCBot v4.
There are now up to 256 priority levels (although I can't imagine using that many). By default, RadioBot uses:
PRIORITY_LOWEST 0 Lowest priority bulk data (mostly LogChan stuff)
PRIORITY_SPAM 1 Slightly higher priority for channel spamming/song updates/etc.
PRIORITY_DEFAULT 10 The default priority for data that isn't specified as another level.
PRIORITY_INTERACTIVE 60 The Interactive priority is for responses from !triggers and other cases where a minimal amount of delay is wanted
PRIORITY_IMMEDIATE 99 The Immediate priority is for data where minimal delay is important. This level is limited to things like server logins/channel operations/ping replies/etc.
WARNING: Technical Data follows!!!
Diagram
This diagram shows an overview of the SendQ priority system.
Data is sent in descending priority (ie. 99 will be sent first, 0 last), all of the data blocks from the highest level will be sent before moving on to lower levels.
Algorithm Implementation
This system could easily be implemented in C structures (linked lists, dynamically allocated arrays, etc.) or in C++ using STL map (for the priority levels) and vectors/queues for the FIFOs.
Algorithm Limitations
Just a note for anyone who wants to implement a similar system. This SendQ was designed for rate-limited IRC connections where there will be lots of times when higher levels will be empty for lower levels to get their data sent. If you use a system where higher priority classes are almost always full you could choke-out the lower levels and the data may never be sent, in order to remedy that you would need to modify the system to not send all data in the highest class before moving on to the next level. This could easily be done by basing the number of data chunks to send on the priority. (ie if there was a Priority of 5 it would send 5 data chunks before moving to the next lower level and looping around back to the highest level when it reaches the bottom)
RadioBot v • d • e
|
---|
RadioBot main pages |
Main Page • Installation • Changelog • Commands • Plugins • FAQ • Configuration • Credits • Remote Client • Built-In Variables • Multi Sound Server Mode • Username Character Restrictions |
Auto DJ Pages |
Auto DJ Main Page • WebRequest System • Scheduler • MP3 Encoder • Voice Support • MySQL Plugin |
RadioBot Programming v • d • e
|
RadioBot Programming |
Plugin API • Remote Commands • Plugin Initialization • RadioBot DB • Changing Command Permissions • ShoutIRC Music Database |
Lua Scripting |
Lua Plugin • Lua Scripting • Lua Events |