Categories: Uncategorized

Using WebSockets with Red5

You may have heard of WebSockets and how powerful they can be. What are they? Essentially WebSockets allow you to open an interactive connection between the server and the client in HTML5 apps. This allows you to make API calls without everything having to go through the server. Quite useful! Especially since this is a low-latency technique that can be used in conjunction with the very low-latency video streaming on Red5 Server. Here are few tips for using WebSockets on Red5.

  1. The WebSocket chat is a great example that you can use to bridge Flash clients and WebSocket clients. Notice how router context is used to route messages between SharedObjects and WebSocket clients.

  2. Remember that in Java these are just 2 objects ApplicationAdapter <=> WebSocketDataListener (see chat example). They exist in the same context governed by red5-web.xml. You can easily setup message passing communication link between then with some programming. Just see the chat example and see how web.handler and WebSocket listener are registered in spring. Then think how to connect them.

  3. You can create a proxy to help each site execute a method on the other side which may conform to a common interface (deal).

  4. Unlike Red5 scopes WebSockets do not really have rooms.ie: ws://localhost:8081/chat/room1/room2 (wont work)

  5. Think of it as a Single level application where there is no depth and create scopes yourself using query params. See this for example. http://www.jpablo128.com/multi-room-websockets-server-with-tornado-i-basic-chat-server/

  6. Instead of thinking of scopes as /room/room2 think like ?room=myroom or ?room=myroom&room=room2 (the later is an array of 2 items defining depth in order as the names appear)

  7. Now use shared objects wisely to spawn as many rooms you want at a single level. name = so+room1, name = so+room1+room2 etc:

  8. WebSockets will also be able to give you the room params as discussed before. (6)

  9. Finally, create your own logic to join both worlds using the unique string that identifies the same room from flash and webSockets. Then make use of the Router concept (as shown in chat example) to relay messaged between the two types of clients for the same room.

Now this is useful with Flash based streaming apps and all, but just imagine all you can do with the Red5Pro WebRTC release coming later this summer! If you are interested in getting early access to the WebRTC beta, then send us an email.

Happy Coding!

Red5 Team

Share
Published by
Red5 Team

Recent Posts

What Is Air-Gapped Streaming, And Why Are More Teams Asking For It?

Hi everyone, Chris Allen here, co-founder and CEO of Red5. I’ve been building live streaming…

12 hours ago

Red5 on OCI vs AWS IVS: Why Oracle Cloud Infrastructure is an Excellent Choice for Live Streaming

As organizations evaluate live streaming solutions, Amazon Interactive Video Service (IVS) has emerged as a…

1 week ago

What’s New in Red5 Cloud v1.9.2? Valuable UI/UX Improvements and Bug Fixes

Let’s go over the latest updates introduced in Red5 Cloud since our previous blog covering…

1 week ago

Real-Time Streaming Solutions for 2025: Red5 vs. Phenix vs. Dolby Optiview

When businesses need ultra-low latency streaming capabilities, the choice of platform can significantly influence the…

2 weeks ago

AWS IVS vs Red5: Choosing the Right Live Streaming Solution for Your Business

1Understanding AWS IVS: Strengths and Limitations2Red5: A More Flexible Alternative3When to Choose Red5 Over AWS…

4 weeks ago

What’s New in Red5 Pro v14.2.1 and Red5 Cloud v1.9.1?

Let’s take a look at the latest Red5 Pro and Red5 Cloud releases introduced since…

1 month ago