Skip to content

Instantly share code, notes, and snippets.

@payden
Created August 12, 2012 01:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save payden/3328764 to your computer and use it in GitHub Desktop.
Save payden/3328764 to your computer and use it in GitHub Desktop.
PHP WebSocket extension based on libwebsock.
How I want my websocket PHP extension to work:
(Something like this)
<?php
set_time_limit(0); //maybe do this inside extension, if possible?
$ws = new WebSocket("3333");
$ws->set_receive_callback(function($state, $msg) {
WebSocket::sendText($state->sockfd, $msg->text);
});
$ws->set_connect_callback(function($state) {
WebSocket::sendText($state->sockfd, "Hello there!");
});
$ws->run();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment