Overview

Namespaces

  • Budabot
    • Core
      • Modules
    • User
      • Modules
  • None
  • Tyrence
    • Modules

Classes

  • AccessLevel
  • Budabot\Core\AccessManager
  • Budabot\Core\AdminManager
  • Budabot\Core\AOChat
  • Budabot\Core\AOChatPacket
  • Budabot\Core\AOChatQueue
  • Budabot\Core\AOExtMsg
  • Budabot\Core\AsyncHttp
  • Budabot\Core\AutoInject
  • Budabot\Core\BotRunner
  • Budabot\Core\Budabot
  • Budabot\Core\BuddylistManager
  • Budabot\Core\CacheManager
  • Budabot\Core\CacheResult
  • Budabot\Core\ClassLoader
  • Budabot\Core\ColorSettingHandler
  • Budabot\Core\CommandAlias
  • Budabot\Core\CommandManager
  • Budabot\Core\ConfigFile
  • Budabot\Core\DB
  • Budabot\Core\DBRow
  • Budabot\Core\EventLoop
  • Budabot\Core\EventManager
  • Budabot\Core\GuildChannelCommandReply
  • Budabot\Core\GuildManager
  • Budabot\Core\HelpManager
  • Budabot\Core\Http
  • Budabot\Core\HttpRequest
  • Budabot\Core\LegacyLogger
  • Budabot\Core\LimitsController
  • Budabot\Core\LoggerWrapper
  • Budabot\Core\MMDBParser
  • Budabot\Core\Modules\AdminController
  • Budabot\Core\Modules\AliasController
  • Budabot\Core\Modules\AltInfo
  • Budabot\Core\Modules\AltsController
  • Budabot\Core\Modules\BanController
  • Budabot\Core\Modules\BuddylistController
  • Budabot\Core\Modules\ColorsController
  • Budabot\Core\Modules\CommandlistController
  • Budabot\Core\Modules\CommandSearchController
  • Budabot\Core\Modules\ConfigController
  • Budabot\Core\Modules\EventlistController
  • Budabot\Core\Modules\HelpController
  • Budabot\Core\Modules\LogsController
  • Budabot\Core\Modules\PlayerLookupController
  • Budabot\Core\Modules\ProfileCommandReply
  • Budabot\Core\Modules\ProfileController
  • Budabot\Core\Modules\SettingsController
  • Budabot\Core\Modules\SQLController
  • Budabot\Core\Modules\SystemController
  • Budabot\Core\Modules\UsageController
  • Budabot\Core\Modules\WhitelistController
  • Budabot\Core\NumberSettingHandler
  • Budabot\Core\OptionsSettingHandler
  • Budabot\Core\PlayerHistory
  • Budabot\Core\PlayerHistoryManager
  • Budabot\Core\PlayerManager
  • Budabot\Core\Preferences
  • Budabot\Core\PrivateChannelCommandReply
  • Budabot\Core\PrivateMessageCommandReply
  • Budabot\Core\Registry
  • Budabot\Core\SettingHandler
  • Budabot\Core\SettingManager
  • Budabot\Core\SettingObject
  • Budabot\Core\SocketManager
  • Budabot\Core\SocketNotifier
  • Budabot\Core\SubcommandManager
  • Budabot\Core\Text
  • Budabot\Core\TextSettingHandler
  • Budabot\Core\Timer
  • Budabot\Core\TimerEvent
  • Budabot\Core\TimeSettingHandler
  • Budabot\Core\Util
  • Budabot\Core\xml
  • Budabot\User\Modules\AlienArmorController
  • Budabot\User\Modules\AlienBioController
  • Budabot\User\Modules\AlienMiscController
  • Budabot\User\Modules\AOSpeakController
  • Budabot\User\Modules\AOUController
  • Budabot\User\Modules\AXPController
  • Budabot\User\Modules\BankController
  • Budabot\User\Modules\BosslootController
  • Budabot\User\Modules\BroadcastController
  • Budabot\User\Modules\BuffPerksController
  • Budabot\User\Modules\CacheController
  • Budabot\User\Modules\ChatAssistController
  • Budabot\User\Modules\ChatCheckController
  • Budabot\User\Modules\ChatLeaderController
  • Budabot\User\Modules\ChatRallyController
  • Budabot\User\Modules\ChatSayController
  • Budabot\User\Modules\ChatTopicController
  • Budabot\User\Modules\CityWaveController
  • Budabot\User\Modules\CloakController
  • Budabot\User\Modules\ClusterController
  • Budabot\User\Modules\CountdownController
  • Budabot\User\Modules\DevController
  • Budabot\User\Modules\DingController
  • Budabot\User\Modules\EventsController
  • Budabot\User\Modules\FightController
  • Budabot\User\Modules\FindOrgController
  • Budabot\User\Modules\FindPlayerController
  • Budabot\User\Modules\FunController
  • Budabot\User\Modules\GitController
  • Budabot\User\Modules\GuideController
  • Budabot\User\Modules\GuildController
  • Budabot\User\Modules\HelpbotController
  • Budabot\User\Modules\HtmlDecodeController
  • Budabot\User\Modules\ImplantController
  • Budabot\User\Modules\ImplantDesignerController
  • Budabot\User\Modules\InactiveMemberController
  • Budabot\User\Modules\ItemsController
  • Budabot\User\Modules\KillOnSightController
  • Budabot\User\Modules\LevelController
  • Budabot\User\Modules\LinksController
  • Budabot\User\Modules\LootListsController
  • Budabot\User\Modules\MdbController
  • Budabot\User\Modules\MessageInfoCommandReply
  • Budabot\User\Modules\MockCommandReply
  • Budabot\User\Modules\NanoController
  • Budabot\User\Modules\NewsController
  • Budabot\User\Modules\NotesController
  • Budabot\User\Modules\OnlineController
  • Budabot\User\Modules\OrgHistoryController
  • Budabot\User\Modules\OrglistController
  • Budabot\User\Modules\OrgMembersController
  • Budabot\User\Modules\OSController
  • Budabot\User\Modules\PlayerHistoryController
  • Budabot\User\Modules\PlayfieldController
  • Budabot\User\Modules\PocketbossController
  • Budabot\User\Modules\PremadeImplantController
  • Budabot\User\Modules\PrivateChannelController
  • Budabot\User\Modules\QuoteController
  • Budabot\User\Modules\RaffleController
  • Budabot\User\Modules\RaidController
  • Budabot\User\Modules\RandomController
  • Budabot\User\Modules\RecipeController
  • Budabot\User\Modules\RelayController
  • Budabot\User\Modules\ReputationController
  • Budabot\User\Modules\ResearchController
  • Budabot\User\Modules\RunAsController
  • Budabot\User\Modules\SendTellController
  • Budabot\User\Modules\ShoppingController
  • Budabot\User\Modules\SilenceController
  • Budabot\User\Modules\SkillsController
  • Budabot\User\Modules\SpiritsController
  • Budabot\User\Modules\StopwatchController
  • Budabot\User\Modules\Teamspeak3
  • Budabot\User\Modules\TeamspeakController
  • Budabot\User\Modules\TestController
  • Budabot\User\Modules\TimeController
  • Budabot\User\Modules\TimerController
  • Budabot\User\Modules\TimezoneController
  • Budabot\User\Modules\TowerController
  • Budabot\User\Modules\TrackerController
  • Budabot\User\Modules\TrickleController
  • Budabot\User\Modules\UnixtimeController
  • Budabot\User\Modules\VoteController
  • Budabot\User\Modules\WeatherController
  • Budabot\User\Modules\WhatBuffsController
  • Budabot\User\Modules\WhereisController
  • Budabot\User\Modules\WhoisController
  • Budabot\User\Modules\WhoisOrgController
  • Budabot\User\Modules\WhompahController
  • Command
  • DefaultStatus
  • DefineCommand
  • Description
  • Event
  • HandlesCommand
  • Help
  • Inject
  • Instance
  • Intoptions
  • Matches
  • Options
  • Setting
  • Setup
  • Type
  • Tyrence\Modules\DemoResponseCommandReply
  • Tyrence\Modules\SameChannelResponseController
  • Visibility

Interfaces

  • Budabot\Core\CommandReply

Exceptions

  • Budabot\Core\InvalidHttpRequest
  • Budabot\Core\SQLException
  • Budabot\Core\StopExecutionException

Functions

  • Budabot\Core\isWindows
  • Budabot\Core\Modules\read_input
  • Overview
  • Namespace
  • Class
 1: <?php
 2: 
 3: namespace Budabot\Core;
 4: 
 5: /**
 6:  * @Instance
 7:  */
 8: class SocketManager {
 9:     private $socketNotifiers = array();
10:     private $monitoredSocketsByType = array();
11:     
12:     public function __construct() {
13:         $this->monitoredSocketsByType[SocketNotifier::ACTIVITY_READ] = array();
14:         $this->monitoredSocketsByType[SocketNotifier::ACTIVITY_WRITE] = array();
15:         $this->monitoredSocketsByType[SocketNotifier::ACTIVITY_ERROR] = array();
16:     }
17:     
18:     public function checkMonitoredSockets() {
19:         $read = $this->monitoredSocketsByType[SocketNotifier::ACTIVITY_READ];
20:         $write = $this->monitoredSocketsByType[SocketNotifier::ACTIVITY_WRITE];
21:         $except = $this->monitoredSocketsByType[SocketNotifier::ACTIVITY_ERROR];
22:         if ($read || $write || $except) {
23:             if (0 < stream_select($read, $write, $except, 0)) {
24:                 foreach ($this->socketNotifiers as $notifier) {
25:                     $socket = $notifier->getSocket();
26:                     $type = $notifier->getType();
27: 
28:                     if (in_array($socket, $read) && $type & SocketNotifier::ACTIVITY_READ) {
29:                         $notifier->notify(SocketNotifier::ACTIVITY_READ);
30:                     }
31:                     if (in_array($socket, $write) && $type & SocketNotifier::ACTIVITY_WRITE) {
32:                         $notifier->notify(SocketNotifier::ACTIVITY_WRITE);
33:                     }
34:                     if (in_array($socket, $except) && $type & SocketNotifier::ACTIVITY_ERROR) {
35:                         $notifier->notify(SocketNotifier::ACTIVITY_ERROR);
36:                     }
37:                 }
38:             }
39:         }
40:     }
41:     
42:     /**
43:      * Adds given socket notifier to list of sockets which are
44:      * monitored for activity.
45:      */
46:     public function addSocketNotifier($socketNotifier) {
47:         $this->socketNotifiers []= $socketNotifier;
48: 
49:         // add the socket to each activity category for faster access in the event loop
50:         if ($socketNotifier->getType() & SocketNotifier::ACTIVITY_READ) {
51:             $this->monitoredSocketsByType[SocketNotifier::ACTIVITY_READ][] = $socketNotifier->getSocket();
52:         }
53:         if ($socketNotifier->getType() & SocketNotifier::ACTIVITY_WRITE) {
54:             $this->monitoredSocketsByType[SocketNotifier::ACTIVITY_WRITE][] = $socketNotifier->getSocket();
55:         }
56:         if ($socketNotifier->getType() & SocketNotifier::ACTIVITY_ERROR) {
57:             $this->monitoredSocketsByType[SocketNotifier::ACTIVITY_ERROR][] = $socketNotifier->getSocket();
58:         }
59:     }
60: 
61:     /**
62:      * Removes given socket notifier from list of sockets being monitored.
63:      */
64:     public function removeSocketNotifier($socketNotifier) {
65:         if (is_object($socketNotifier) == false) {
66:             return;
67:         }
68: 
69:         $this->removeOne($this->socketNotifiers, $socketNotifier);
70: 
71:         if ($socketNotifier->getType() & SocketNotifier::ACTIVITY_READ) {
72:             $this->removeOne($this->monitoredSocketsByType[SocketNotifier::ACTIVITY_READ], $socketNotifier->getSocket());
73:         }
74:         if ($socketNotifier->getType() & SocketNotifier::ACTIVITY_WRITE) {
75:             $this->removeOne($this->monitoredSocketsByType[SocketNotifier::ACTIVITY_WRITE], $socketNotifier->getSocket());
76:         }
77:         if ($socketNotifier->getType() & SocketNotifier::ACTIVITY_ERROR) {
78:             $this->removeOne($this->monitoredSocketsByType[SocketNotifier::ACTIVITY_ERROR], $socketNotifier->getSocket());
79:         }
80:     }
81:     
82:     private function removeOne(&$array, $value) {
83:         $key = array_search($value, $array, true);
84:         if ($key !== false) {
85:             unset($array[$key]);
86:         }
87:     }
88: }
89: 
Budabot 4 Docs API documentation generated by ApiGen