<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">Centrifugo::Client

Centrifugo::Client : A server-side Perl client for centrifugo

https://github.com/Orabig/centrifugo-perl-client

This module can be used to connect to a Centrifugo server with WebSockets.

More info about Centrifugo :
https://github.com/centrifugal/centrifugo or https://fzambia.gitbooks.io/centrifugal/content/

INSTALLATION

To install this module, run the following commands:

	perl Makefile.PL
	make
	make install
	
SUPPORT AND DOCUMENTATION

After installing, you can find documentation for this module with the
perldoc command.

	perldoc Centrifugo::Client

EXAMPLE

Note : To connect to a Centrifugo instance, your program should first ask for a TOKEN. This part is not covered by this module, because it is implementation-dependant.

	use Centrifugo::Client;
	use AnyEvent;

	my $cclient = Centrifugo::Client-&gt;new("$CENTRIFUGO_WS/connection/websocket");

	$cclient-&gt;connect(
		user      =&gt; $USER_ID,
		timestamp =&gt; $TIMESTAMP,
		token     =&gt; $TOKEN
	) -&gt; on('connect', sub{
		my ($infoRef)=@_;
		print "Connected to Centrifugo version ".$infoRef-&gt;{version};
		# When connected, connect to some channel
		$cclient-&gt;subscribe( $CHANNEL );
	})-&gt; on('message', sub{
		my ($infoRef)=@_;
		print "Received message : ".encode_json $infoRef-&gt;{data};
	});

	# Now start the event loop to keep the program alive
	AnyEvent-&gt;condvar-&gt;recv;</pre></body></html>