Verified Commit 067c6404 authored by Lorenzo Setale's avatar Lorenzo Setale
Browse files

to avoid increasing websockets channels we encourage to reuse the same browser


source

Signed-off-by: Lorenzo Setale's avatarLorenzo Setale <lorenzo@setale.me>
parent b66ee4fe
......@@ -56,13 +56,13 @@ By default this url will be [http://localhost:8000/](http://localhost:8000/).
If you are running on a different platform like Heroku or DigitalOcean please
use the URL provided by those platforms.
Remember to enable the following options:
Remember to have dibled the following options:
- Refresh browser when scene becomes active
- Shutdown source when not visible
The reason is this that this uses WebSockets and it is better to no have
_multiple listners_ at the same time (aka: reuse the same source by
_Copy Reference_)
_Copy Reference_). In case of issues the web page should reconnect automagically
### Adding files
You can add files any time into the `assets` directory (please note that the
......
package http
import (
log "github.com/sirupsen/logrus"
)
var (
WSListnerChannels []chan string
)
......@@ -9,7 +13,18 @@ var (
// This allows to have multiple browser source connecting on different
// web sockets at the same time.
func channelPipe(mainChannel chan string) {
logWF := log.WithFields(log.Fields{
"f": "http.channelPipe",
})
logWF.Debug("Starting the Channel Pipe")
for msg := range mainChannel {
log.WithFields(log.Fields{
"msg": msg,
"channels": len(WSListnerChannels),
}).Debug("Sending messages to web socket channels")
for _, ch := range WSListnerChannels {
ch <- msg
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment