ColdFusion WebSockets are lightning fast and presents an opportunity to create realtime applications. This time I've created an application that tries to push HTML5 video content over a WebSocket. The idea here is to use a temporary Canvas, since it allows you to draw a video frame on it and then transfer the contents of the drawn video frame (as base64 encoded Image) over a ColdFusion WebSocket channel to the subscribers.
I've posted this on my blog along with the demo video and code. Check out Pushing HTML5 Video content over ColdFusion WebSockets.
The very first and easy step to setup WebSocket is to use the default Channel Listener .But if you need to implement business logic to control the WebSocket system in your application you will have to use a custom Channel Listener CFC.
Channel Listener has six methods which can be used to control
- who is allowed to publish data over a websocket channel
- who is eligible to recieve data
over a websocket channel
- how to present data to different users
For more details on how to implement the logic to restrict the right to publish data , read my blog entry - ColdFusion WebSocket Part4:Restricting Right to Publish
Most of the ColdFusion WebSocket responses are asynchronous, which essentially means that the response to your WebSocket method calls (such as getSubscriberCount, getSubscriptions, publish, invokeAndPublish, or invoke) come to message handler.
Since there are different types of responses and all of them come to the message handler, application developer has to interpret each response, figure out the operation that triggered, and show the responses appropriately.
Let us try to crack how to categorize the responses received.For more details checkout my thrid entry on ColdFusion Websocket blog series
With ColdFusion 10 we have revamped the CFMEDIAPLAYER tag to provide support for HTML5 Videos.
The CFMEDIAPLAYER tag is now bundled with device support , so you can build your video based applications and play them over iPADs and Android devices.
You can even enforce a particular type of playback on your browser using the newly added ' type' attribute and provide fallback using the HTML source tag .
Here is my blog post listing a few snippets that show the different ways in which we use CFMEDIPLAYER to support HTML5 videos,and a few tips and tricks! You can also download some sample videos from the link.
The most vital part of ColdFusion WebSocket feature is the ability to push live data. You can publish data either from server to mulitple clients or from one client to multiple clients. ColdFusion Websockets provides you different methods , that could be used to publish data. Lets try to find out how these different methods are used.
Here is my blogpost on different ways to publish data using ColdFusion WebSocket. Checkout the application provided which will help you get started with ColdFusion WebSocket implementation.