1: <?php
2: namespace Ratchet;
3:
4: /**
5: * This is the interface to build a Ratchet application with.
6: * It implements the decorator pattern to build an application stack
7: */
8: interface ComponentInterface {
9: /**
10: * When a new connection is opened it will be passed to this method
11: * @param ConnectionInterface $conn The socket/connection that just connected to your application
12: * @throws \Exception
13: */
14: function onOpen(ConnectionInterface $conn);
15:
16: /**
17: * This is called before or after a socket is closed (depends on how it's closed). SendMessage to $conn will not result in an error if it has already been closed.
18: * @param ConnectionInterface $conn The socket/connection that is closing/closed
19: * @throws \Exception
20: */
21: function onClose(ConnectionInterface $conn);
22:
23: /**
24: * If there is an error with one of the sockets, or somewhere in the application where an Exception is thrown,
25: * the Exception is sent back down the stack, handled by the Server and bubbled back up the application through this method
26: * @param ConnectionInterface $conn
27: * @param \Exception $e
28: * @throws \Exception
29: */
30: function onError(ConnectionInterface $conn, \Exception $e);
31: }
32: