Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/GulDmitry/php-websocket-server
PHP WebSocket Server for PHP 5.3
https://github.com/GulDmitry/php-websocket-server
Last synced: about 2 months ago
JSON representation
PHP WebSocket Server for PHP 5.3
- Host: GitHub
- URL: https://github.com/GulDmitry/php-websocket-server
- Owner: GulDmitry
- Created: 2011-07-08T16:36:48.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-07-29T16:49:48.000Z (over 12 years ago)
- Last Synced: 2024-08-03T05:02:31.786Z (5 months ago)
- Language: ActionScript
- Homepage:
- Size: 1.34 MB
- Stars: 28
- Watchers: 4
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-actionscript-sorted - php-websocket-server - PHP WebSocket Server for PHP 5.3 (Networking / Sockets)
README
PHP WebSocket Server
====================Based on [php-websocket](https://github.com/nicokaiser/php-websocket) by Nico Kaiser
Used websocket [protocol 10](http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10) or higher.
If you want more powerful server see: [Jeff Morgan websocket server](https://github.com/jam1401/PHP-Websockets-Server), also you can look in the direction of the [this](https://github.com/lemmingzshadow/php-websocket) server, especially for php client implementation. :-)
##Changes
### 1. Native namespaces
### 2. New methods
### 3. Draft-ietf-hybi-thewebsocketprotocol-10+
####Connection object.
Send\broadcast to all server, application and group connections.
/**
* Send to current socket
*
* @param string $data
*/
public function send($data)-------------------------------------------------------
/**
* Send to all server sockets
*
* @param string $message
*/
public function sendServer($message)/**
* Broadcats to all server sockets
*
* @param string $message
*/
public function broadcastServer($message)-------------------------------------------------------
/**
* Custom counter increment
*
* @param int $num
*/
public function incrementMsgStack($num)/**
* Custom counter decrement
*
* @param int $num
*/
public function decrementMsgStack($num)/**
* Reset counter
*/
public function resetMsgStack()-------------------------------------------------------
/**
* Socket standing
*
* @return bool TRUE if socket open, else FALSE
*/
public function getSocketAlive()-------------------------------------------------------
/**
* Send to current connection group if $key = false
*
* @param mixed $key Group identifier
* @param string $message
*/
public function sendGroup($message, $key = false)/**
* Broadcast to current connection group if $key = false
*
* @param mixed $key Group identifier
* @param string $message
*/
public function broadcastGroup($message, $key = false)/**
*
* @param mixed $key
* @param Connection $connection
*/
public function setGroup($key)/**
* @param mixed $key
* @return mixe Connections in group with $key, or false if group not exists
*/
public function getConnectionsByGroupKey($key)/**
* Get current socket group key
*
* @return mixed Group key or false
*/
public function getGroup()#### Application class.
/**
* Send to application sockets
*
* @param string $message
*/
public function sendApp($message)/**
* Send to application sockets with exclude
*
* @param Connection $excludeConnection
* @param string $message
*/
public function broadcastApp($excludeConnection, $message)## Start
1. Register application(s) (server.php)
2. Start server: php server.php
Run server script as root (and port 843(!)). If you want custom user or port run other script
that listens on port 843 and returns a Socket Policy XML string for Flash players.
(See http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security_04.html for details.)2. Connect to applicaton: run client/index.html in browser
## Client
See client/index.html
## Libraries used
- [php-websocket](https://github.com/nicokaiser/php-websocket) by Nico Kaiser
- [phpWebSockets](http://code.google.com/p/phpwebsockets/) by Moritz Wutz
- Simon Samtleben - hybi 10 encode
- [web-socket-js](http://github.com/gimite/web-socket-js) by Hiroshi Ichikawa (example)
- [jQuery](http://jquery.com/) (example)