An open API service indexing awesome lists of open source software.

https://github.com/red5/red5-websocket-chat

Red5 WebSocket Chat Demo
https://github.com/red5/red5-websocket-chat

Last synced: 3 months ago
JSON representation

Red5 WebSocket Chat Demo

Awesome Lists containing this project

README

          

# Chat application

Red5 chat application example.

The example `index.html` defaults to using a WebSocket connection; SSE is also supported. Change the host and port entries to match your server as needed.

## Add the WebSocket filter servlet to webapps that require WebSocket support

```xml

WebSocketFilter
org.red5.net.websocket.server.WsFilter
true


WebSocketFilter
/*
REQUEST
FORWARD

```

## Add the SSE servlet to webapps that require SSE support

```xml

sse
org.red5.server.net.sse.SSEServlet
-1
true


cors.enabled
false



sse
/events
/events/*

```

## Build and Deploy

Build the application from the command line with

```sh
mvn package
```

If you are using Red5 Pro, you will need to modify the WebSocket connection URL to include the appropriate capabilities parameter:

```javascript
/*
if we're hitting a red5pro server, ensure the port is 5080 and wsonly is true (for websocket only mode)
?capabilities=1 : WebSocket Connection only
?capabilities=3 : RTCConnection
*/
var socket = new WebSocket(protocol + '://' + window.location.hostname + ':' + port + '/chat/?capabilities=1', 'chat');
// std red5
//var socket = new WebSocket(protocol + '://' + window.location.hostname + ':' + port + '/chat', 'chat');
```

Deploy your application by copying the war file into your `red5/webapps` directory. If the war file does not deploy withing a few minutes, this may indicate the war deployer bean is not created or running; a work-around is to expand the war contents into the webapps directory manually and restart Red5.

After deploy is complete, go to http://localhost:5080/chat/ in your browser (open two tabs if you want to chat back and forth on the same computer).

## Pre-compiled WAR

You can find [compiled artifacts via Maven](http://mvnrepository.com/artifact/org.red5.demos/chat)

[Direct Download](https://oss.sonatype.org/content/repositories/releases/org/red5/demos/chat/2.0.23/chat-2.0.23.war)