Skip to content

nickolanack/push-php-socket-io-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-socket-io-client

socketio client wrapper

This is a php 'push event' emitter for use with a customized socketio server. see https://github.com/nickolanack/push-socket-io-server which allows (js browser clients) to subscribe to event channels

#Install

Install push-socket-io-server first.

	
	git clone https://github.com/nickolanack/push-socket-io-server.git
	cd push-socket-io-server
	composer install
	#change to match your credentials
	echo '{"url":"https://your-socket-io-server", "username" : "someusername", "password" : "somepassword", "appId" : "someappid"}' | credentials.json

Test

	php test.php 

#Usage (Emitter)

	include_once __DIR__ . '/vendor/autoload.php';

	$credentials=json_decode(file_get_contents(__DIR__.'/credentials.json'));
	(new \socketio\Client($credentials->url, $credentials))
	->broadcast('chat', 'message', "Hello World");

you can listen to event streams, (but use nodejs instead if possible)

#Usage (Listener)

	include_once __DIR__ . '/vendor/autoload.php';

	$credentials=json_decode(file_get_contents(__DIR__.'/credentials.json'));
	(new \socketio\Client($credentials->url, $credentials))
		->on('chat', 'message', function($message){

			print_r($message);

		})
		->listen(); //never returns!!!

About

socketio client wrapper

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages