Download the PHP package stas-zozulja/pushpin-bundle without Composer
On this page you can find all versions of the php package stas-zozulja/pushpin-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stas-zozulja/pushpin-bundle
More information about stas-zozulja/pushpin-bundle
Files in stas-zozulja/pushpin-bundle
Package pushpin-bundle
Short Description Pushpin proxy integration for Symfony applications
License MIT
Informations about the package pushpin-bundle
GammaPushpinBundle
Symfony Bundle that helps you to add a realtime features to your applications using Pushpin reverse proxy. Integrates php-gripcontrol library.
Features
- WebSocket-over-HTTP
- Works with WebSocket-over-HTTP Requests from Pushpin
- De serializes (using jms/serializer) a TEXT events from Pushpin into DTOs (events) specified by your configuration
- Handling WebSocketEvent with your specific handler
- Pushpin helpers to publishing to a channel, subscribing, detaching etc.
- HTTP streaming
- adds a specific response headers for Pushipn to hold a connections HTTP GRIP transport
Installation
Install a bundle
composer require "stas-zozulja/pushpin-bundle"
Register the bundle in app/AppKernel.php
:
Configuration
For testing you need to install a Pushpin on dev machine. And enable WebSocket-over-HTTP in config file:
Usage (WebSocket-over-HTTP)
Create an event class. Extend . This class will hold a data from websocket clients:
Update configuration with your new event:
Create handler service for your event by extending class: ` Here you can return a single WebSocketEvent, array of WebSocketEvent objects or WebSocketEventsDTO that holds events as array as well. Register handler as a Symfony service:
Note: Here is should be similar to logical name of event in configuration.
And last thing you need to do is to create a simple controller that Pushpin will access. Using annotation we can return just instance from handler.
If everything is ok you should be able to connect to Pushpin's websocket port (7999 by default) with URL:
ws://localhost:7999/websocket/chat
You can test with wscat utility:
Now clients can send a message to your application:
This will call your handler and return a result back to a client.
Working with channels
Pushpin works as a publish-subscribe service. So you have ability to subscribe clients to a specific channels and publish a messages to it. Anything that can be a channel in your application should implement a with one method . To publish messages you can also use
By calling methods on you can:
- subscribe client to a channel
- publish to a channel
- unsubscribe from channel
- detach connection
Here is additional info on Pushpin
Example of working application
TODO
- documentation on HTTP-stream
- more
All versions of pushpin-bundle with dependencies
fanout/gripcontrol Version ^2.0
symfony/console Version ~2.3|~3.4
symfony/framework-bundle Version ~2.3|~3.4
jms/serializer Version ^1.1
sensio/framework-extra-bundle Version ^5.1
doctrine/common Version ^2.7