Handles the "Connect" event.

\param Erebot::Interfaces::EventHandler $handler
The event handler responsible for calling
this method.

\param Erebot::Interfaces::Event::Connect $event
The "Connect" event to process.
175260
public function handleConnect(
        \Erebot\Interfaces\EventHandler $handler,
        \Erebot\Interfaces\Event\Connect $event
    ) {
        $this->connected = true;
    }
677021
public function handleConnect()
    {
        $socket = @stream_socket_accept($this->socket);

        if ($socket === false)
        {
            $this->emit('error', [ $this, new ReadException('Socket could not accept new connection.') ]);
            return;
        }

        $client = null;
        $ex = null;

        try
        {
            $client = $this->createClient($socket, [
                'ssl' => $this->config['ssl'],
                'ssl_method' => $this->config['ssl_method'],
            ]);

            $this->emit('connect', [ $this, $client ]);
        }
        catch (Error $ex)
        {}
        catch (Exception $ex)
        {}

        if ($ex !== null)
        {
            $this->handleDisconnect($socket);
            $this->emit('error', [ $this, new ReadException('Socket could not wrap new connection!') ]);
        }
    }
393286
public function handle( $handler = '' ) {
		if ( ! empty( $handler ) ) {
			$this->attribute( 'handler', $handler );
		}

		$this->router->addRoute( $this->router->route( $this->getAttributes() ) );
	}
738510
public function on($event_name, $handler_callback)
    {
        $event = null;
        if (!isset($this->event_queue[$event_name])) {
            $event = new Event($event_name);
            $this->event_queue[$event_name] = $event;
        }

        $event = $this->event_queue[$event_name];
        $event->setHandlerCallback($handler_callback);
    }
1226709
private function send_to_handler() {
        try {
            mtrace("--> Passing to Inbound Message handler {$this->addressmanager->get_handler()->classname}");
            if ($result = $this->addressmanager->handle_message($this->currentmessagedata)) {
                $this->inform_user_of_success($this->currentmessagedata, $result);
                // Request that this message be marked for deletion.
                return true;
            }

        } catch (\core\message\inbound\processing_failed_exception $e) {
            mtrace("-> The Inbound Message handler threw an exception. Unable to process this message. The user has been informed.");
            mtrace("--> " . $e->getMessage());
            // Throw the exception again, with additional data.
            $error = new \stdClass();
            $error->subject     = $this->currentmessagedata->envelope->subject;
            $error->message     = $e->getMessage();
            throw new \core\message\inbound\processing_failed_exception('messageprocessingfailed', 'tool_messageinbound', $error);

        } catch (\Exception $e) {
            mtrace("-> The Inbound Message handler threw an exception. Unable to process this message. User informed.");
            mtrace("--> " . $e->getMessage());
            // An unknown error occurred. Still inform the user but, this time do not include the specific
            // message information.
            $error = new \stdClass();
            $error->subject     = $this->currentmessagedata->envelope->subject;
            throw new \core\message\inbound\processing_failed_exception('messageprocessingfailedunknown',
                    'tool_messageinbound', $error);

        }

        // Something went wrong and the message was not handled well in the Inbound Message handler.
        mtrace("-> The Inbound Message handler reported an error. The message may not have been processed.");

        // It is the responsiblity of the handler to throw an appropriate exception if the message was not processed.
        // Do not inform the user at this point.
        return false;
    }
204232
public function connect()
    {
        if ($this->connected === true) {
            return;
        }
        if ($this->_contextOption) {
            $context = stream_context_create($this->_contextOption);
            $this->_socket = stream_socket_client("udp://{$this->_remoteAddress}", $errno, $errmsg,
                30, STREAM_CLIENT_CONNECT, $context);
        } else {
            $this->_socket = stream_socket_client("udp://{$this->_remoteAddress}", $errno, $errmsg);
        }

        if (!$this->_socket) {
            Worker::safeEcho(new \Exception($errmsg));
            return;
        }
        
        stream_set_blocking($this->_socket, false);
        
        if ($this->onMessage) {
            Worker::$globalEvent->add($this->_socket, EventInterface::EV_READ, array($this, 'baseRead'));
        }
        $this->connected = true;
        // Try to emit onConnect callback.
        if ($this->onConnect) {
            try {
                call_user_func($this->onConnect, $this);
            } catch (\Exception $e) {
                Worker::log($e);
                exit(250);
            } catch (\Error $e) {
                Worker::log($e);
                exit(250);
            }
        }
    }
1279184
def event_handler(event)
      case event.command
      when :shutdown
        shutdown_handler(event)
        @run = false
      when :perform
        perform_handler(event)
      else
        raise Workers::UnknownEventError, "Unhandled event (#{event.inspect})."
      end

      nil
    end
766115
def exec_event_handler(self, event, transactional=False):
        """"""
        # QUESTION: Should we raise an exception if `event` is not in some
        # known event-type list?

        callbacks = self._options.get('callbacks', {})

        handler = callbacks.get(event)

        if not handler:
            raise Exception('Handler not defined!!!')

        handler.start(transactional=transactional)
1165095
public function handler($handler)
    {
        if ($this->formDtoMappingCallback) {
            if (!($handler instanceof IParameterizedActionHandler)) {
                list($handler, $parameterDtoType) = $this->wrapArrayParameterAsDto($handler);
                $handler = new CustomParameterizedActionHandler($handler, $this->returnDtoType, $parameterDtoType);
            }

            /** @var IStagedFormDtoMapping $mapping */
            $mapping = call_user_func($this->formDtoMappingCallback, $handler->getParameterTypeClass());

            call_user_func($this->callback, new ParameterizedAction(
                $this->name,
                $this->authSystem,
                $this->requiredPermissions,
                $mapping,
                $handler,
                $this->metadata
            ));
        } else {

            if (!($handler instanceof IUnparameterizedActionHandler)) {
                $handler = new CustomUnparameterizedActionHandler($handler, $this->returnDtoType);
            }

            call_user_func($this->callback, new UnparameterizedAction(
                $this->name,
                $this->authSystem,
                $this->requiredPermissions,
                $handler,
                $this->metadata
            ));
        }
    }
958954
public function handle($event)
    {
        $eventName = $this->getEventName($event);

        if ($this->listenerIsRegistered($eventName))
        {
            return call_user_func([$this, 'when'.$eventName], $event);
        }
    }
621279
public function on(string $event, $handler)
    {
        if (self::isSupportedEvent($event)) {
            $this->options[$event] = $handler;
        }
    }
320667
public function handleSubscribeCallback($message, $expr, callable $handler)
    {
        $event = $this->translator->translate($message);
        if ($event) {
            // we were able to translate the message into an event
            if ($event->matches($expr)) {
                // the event matches the listen expression
                call_user_func($handler, $event);
            } else {
                // pass to listen expr fail handler?
                if ($this->listenExprFailHandler) {
                    call_user_func($this->listenExprFailHandler, $event, $expr);
                }
            }
        } else {
            // pass to translate fail handler?
            if ($this->translateFailHandler) {
                call_user_func($this->translateFailHandler, $message);
            }
        }
    }
478237
public function addEventHandler($name, $handler, array $params = []) {
        if (is_string($handler)) {
            $this->eventHandlers[$name] = [
                'handler' => $handler,
                'params' => $params,
            ];
        } else {
            $this->eventHandlers[$name] = $handler;
        }

        return $this;
    }
655804
public function call(string $event, $data = null)
    {
        if (!$this->eventExists($event)) {
            return;
        }

        // inject request param on connect event
        $isConnect = $event === static::EVENT_CONNECT;
        $dataKey   = $isConnect ? 'request' : 'data';

        return $this->app->invoke($this->callbacks[$event], [
            'websocket' => $this,
            $dataKey    => $data,
        ]);
    }
1074750
public function eventCall()
    {
        try {
            //Daemon::log('cb - '.Debug::zdump($this->cb));
            $func = $this->cb;
            $func($this);
        } catch (\Exception $e) {
            Daemon::uncaughtExceptionHandler($e);
        }
    }
316921
protected function fireConnectionEvent($event)
	{
		if (isset($this->events))
		{
			$this->events->fire('connection.'.$this->getName().'.'.$event, $this);
		}
	}
714056
function handleConnection(socket) { // server 'connect'
		socket.setEncoding('utf-8')
		socket.on('data', requestResponder)

		function requestResponder(data) {
			socket.end(String(process.pid))
			self.emit('data', data)
		}
	}