1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-22 15:02: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() s.Close()
return return
} }
name := strings.TrimSpace(string(buff[:n])) + "@text" name := strings.TrimSpace(string(buff[:n]))
if len(name) < 1 { if len(name) < 1 {
// Too short, exit // Too short, exit
s.Close() s.Close()
@ -69,7 +69,7 @@ func handleViewer(s net.Conn, streams *messaging.Streams, cfg *Options) {
// Get requested stream // Get requested stream
stream, err := streams.Get(name) stream, err := streams.Get(name)
if err != nil { 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 { if _, err := s.Write([]byte("This stream is inactive.\n")); err != nil {
log.Printf("Error while writing to TCP socket: %s", err) 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 // Get requested quality
// FIXME: make qualities available qualityName := "text"
qualityName := "source"
q, err := stream.GetQuality(qualityName) q, err := stream.GetQuality(qualityName)
if err != nil { 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() s.Close()
return return
} }

View File

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