<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="eventhttp.setdefaultcallback" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>EventHttp::setDefaultCallback</refname>
  <refpurpose>Sets default callback to handle requests that are not caught by specific callbacks</refpurpose>
 </refnamediv>
 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <modifier>public</modifier>
   <type>void</type>
   <methodname>EventHttp::setDefaultCallback</methodname>
   <methodparam>
    <type>string</type>
    <parameter>cb</parameter>
   </methodparam>
   <methodparam choice="opt">
    <type>string</type>
    <parameter>arg</parameter>
   </methodparam>
  </methodsynopsis>
  <para>
   Sets default callback to handle requests that are not caught by specific
   callbacks
  </para>
 </refsect1>
 <refsect1 role="parameters">
  &reftitle.parameters;
  <variablelist>
   <varlistentry>
    <term>
     <parameter>cb</parameter>
    </term>
    <listitem>
     <para>
      The callback
      <type>callable</type>
      . It should match the following prototype:
     </para>
     <methodsynopsis>
      <type>void</type>
      <methodname>callback</methodname>
      <methodparam
        choice="opt">
       <type>EventHttpRequest</type>
       <parameter>req</parameter>
       <initializer>NULL</initializer>
      </methodparam>
      <methodparam
        choice="opt">
       <type>mixed</type>
       <parameter>arg</parameter>
       <initializer>NULL</initializer>
      </methodparam>
     </methodsynopsis>
     <para>
      <variablelist>
       <varlistentry>
        <term>
         <parameter>req</parameter>
        </term>
        <listitem>
         <para>
          <classname>EventHttpRequest</classname>
          object.
         </para>
        </listitem>
       </varlistentry>
       <varlistentry>
        <term>
         <parameter>arg</parameter>
        </term>
        <listitem>
         <para>
          Custom data.
         </para>
        </listitem>
       </varlistentry>
      </variablelist>
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term>
     <parameter>arg</parameter>
    </term>
    <listitem>
     <para>
      User custom data passed to the callback.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>
 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   &return.success;
  </para>
 </refsect1>
 <refsect1 role="examples">
  &reftitle.examples;
  <example>
   <title>
    <function>EventHttp::setDefaultCallback</function> example</title>
   <programlisting role="php">
<![CDATA[
<?php
$base = new EventBase();
$http = new EventHttp($base);

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

if (!$http->bind("127.0.0.1", 8088)) {
    exit("bind(1) failed\n");
};

$http->setDefaultCallback(function($req) {
    echo "URI: ", $req->getUri(), PHP_EOL;
    $req->sendReply(200, "OK");
});

$base->dispatch();
?>
]]>
   </programlisting>
  </example>
 </refsect1>
 <refsect1 role="seealso">
  &reftitle.seealso;
  <simplelist>
   <member>
    <methodname>EventHttp::setCallback</methodname>
   </member>
  </simplelist>
 </refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
