1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-22 09:12:19 +00:00

Fix viewer count

This commit is contained in:
Alexandre Iooss 2020-10-19 20:05:20 +02:00
parent d263f743f7
commit e848d92a1a
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
2 changed files with 8 additions and 5 deletions

View File

@ -56,7 +56,7 @@ func handleViewer(s net.Conn, streams *messaging.Streams, cfg *Options) {
s.Close()
return
}
name := strings.TrimSpace(string(buff[:n])) + "@text"
name := strings.TrimSpace(string(buff[:n]))
if len(name) < 1 {
// Too short, exit
s.Close()
@ -69,7 +69,7 @@ func handleViewer(s net.Conn, streams *messaging.Streams, cfg *Options) {
// Get requested stream
stream, err := streams.Get(name)
if err != nil {
log.Printf("Stream does not exist, kicking new Telnet viewer: %s", err)
log.Printf("Kicking new Telnet viewer: %s", err)
if _, err := s.Write([]byte("This stream is inactive.\n")); err != nil {
log.Printf("Error while writing to TCP socket: %s", err)
}
@ -78,11 +78,13 @@ func handleViewer(s net.Conn, streams *messaging.Streams, cfg *Options) {
}
// Get requested quality
// FIXME: make qualities available
qualityName := "source"
qualityName := "text"
q, err := stream.GetQuality(qualityName)
if err != nil {
log.Printf("Failed to get quality: %s", err)
log.Printf("Kicking new Telnet viewer: %s", err)
if _, err := s.Write([]byte("This stream is not converted to text.\n")); err != nil {
log.Printf("Error while writing to TCP socket: %s", err)
}
s.Close()
return
}

View File

@ -157,6 +157,7 @@ func statisticsHandler(w http.ResponseWriter, r *http.Request) {
stream, err := streams.Get(name)
if err == nil {
userCount = stream.ClientCount()
userCount += webrtc.GetNumberConnectedSessions(name)
}
// Display connected users statistics