typo & link fixes
[mdref/mdref-pq] / pq / Connection / listen.md
1 # void pq\Connection::listen(string $channel, callable $listener)
2
3 Listen on $channel for notifications.
4 See pq\Connection::unlisten().
5
6 ## Params:
7
8 * string $channel
9 The channel to listen on.
10 * callable $listener as function(string $channel, string $message, int $pid)
11 A callback automatically called whenever a notification on $channel arrives.
12
13 ## Throws:
14
15 * pq\Exception\InvalidArgumentException
16 * pq\Exception\BadMethodCallException
17 * pq\Exception\RuntimeException
18
19 ## Example:
20
21 <?php
22
23 $conn = new pq\Connection;
24 $conn->listen("queue", function($channel, $message, $backend_pid) {
25 printf("Connection on backend %d said %s\n", $backend_pid, $message);
26 });
27
28 ?>