| Total Complexity | 4 |
| Total Lines | 24 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | #!/usr/bin/env php |
||
| 6 | class echoServer extends WebSocketServer |
||
| 7 | { |
||
| 8 | public function __construct($addr, $port, $bufferLength) |
||
| 9 | { |
||
| 10 | parent::__construct($addr, $port, $bufferLength); |
||
| 11 | $this->userClass = 'MyUser'; |
||
| 12 | } |
||
| 13 | |||
| 14 | //protected $maxBufferSize = 1048576; //1MB... overkill for an echo server, but potentially plausible for other applications. |
||
| 15 | |||
| 16 | protected function process($user, $message) |
||
| 19 | } |
||
| 20 | |||
| 21 | protected function connected($user) |
||
| 22 | { |
||
| 23 | // Do nothing: This is just an echo server, there's no need to track the user. |
||
| 24 | // However, if we did care about the users, we would probably have a cookie to |
||
| 25 | // parse at this step, would be looking them up in permanent storage, etc. |
||
| 26 | } |
||
| 27 | |||
| 28 | protected function closed($user) |
||
| 30 | // Do nothing: This is where cleanup would go, in case the user had any sort of |
||
| 31 | // open files or other objects associated with them. This runs after the socket |
||
| 32 | // has been closed, so there is no need to clean up the socket itself here. |
||
| 43 |