mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add members & host to stats.
This commit is contained in:
parent
bbae073104
commit
b96ba47224
@ -33,7 +33,7 @@ For n.eko room management software visit https://github.com/m1k1o/neko-rooms.
|
|||||||
- Added `VIDEO_BITRATE` and `AUDIO_BITRATE` in kbit/s to control stream quality (in collaboration with @mbattista).
|
- Added `VIDEO_BITRATE` and `AUDIO_BITRATE` in kbit/s to control stream quality (in collaboration with @mbattista).
|
||||||
- Added `MAX_FPS`, where you can specify max WebRTC frame rate. When set to `0`, frame rate won't be capped and you can enjoy your real `60fps` experience. Originally, it was constant at `25fps`.
|
- Added `MAX_FPS`, where you can specify max WebRTC frame rate. When set to `0`, frame rate won't be capped and you can enjoy your real `60fps` experience. Originally, it was constant at `25fps`.
|
||||||
- Invite links. You can invite people and they don't need to enter passwords by themselves (and get confused about user accounts that do not exits). You can put your password in URL using `?pwd=<your-password>` and it will be automatically used when logging in.
|
- Invite links. You can invite people and they don't need to enter passwords by themselves (and get confused about user accounts that do not exits). You can put your password in URL using `?pwd=<your-password>` and it will be automatically used when logging in.
|
||||||
- Added `/stats?pwd=<admin>` endpoint to get total active connections.
|
- Added `/stats?pwd=<admin>` endpoint to get total active connections, host and members.
|
||||||
|
|
||||||
### Bugs
|
### Bugs
|
||||||
- Fixed minor gst pipeline bug.
|
- Fixed minor gst pipeline bug.
|
||||||
|
@ -51,11 +51,9 @@ func New(conf *config.Server, webSocketHandler types.WebSocketHandler) *Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
if err := json.NewEncoder(w).Encode(struct{
|
|
||||||
Connections uint32 `json:"connections"`
|
stats := webSocketHandler.Stats()
|
||||||
}{
|
if err := json.NewEncoder(w).Encode(stats); err != nil {
|
||||||
Connections: webSocketHandler.TotalConns(),
|
|
||||||
}); err != nil {
|
|
||||||
logger.Warn().Err(err).Msg("failed writing json error response")
|
logger.Warn().Err(err).Msg("failed writing json error response")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -2,6 +2,12 @@ package types
|
|||||||
|
|
||||||
import "net/http"
|
import "net/http"
|
||||||
|
|
||||||
|
type Stats struct {
|
||||||
|
Connections uint32 `json:"connections"`
|
||||||
|
Host string `json:"host"`
|
||||||
|
Members []*Member `json:"members"`
|
||||||
|
}
|
||||||
|
|
||||||
type WebSocket interface {
|
type WebSocket interface {
|
||||||
Address() string
|
Address() string
|
||||||
Send(v interface{}) error
|
Send(v interface{}) error
|
||||||
@ -12,6 +18,6 @@ type WebSocketHandler interface {
|
|||||||
Start() error
|
Start() error
|
||||||
Shutdown() error
|
Shutdown() error
|
||||||
Upgrade(w http.ResponseWriter, r *http.Request) error
|
Upgrade(w http.ResponseWriter, r *http.Request) error
|
||||||
TotalConns() uint32
|
Stats() Stats
|
||||||
IsAdmin(password string) (bool, error)
|
IsAdmin(password string) (bool, error)
|
||||||
}
|
}
|
||||||
|
@ -198,8 +198,18 @@ func (ws *WebSocketHandler) Upgrade(w http.ResponseWriter, r *http.Request) erro
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WebSocketHandler) TotalConns() uint32 {
|
func (ws *WebSocketHandler) Stats() types.Stats {
|
||||||
return atomic.LoadUint32(&ws.conns)
|
host := ""
|
||||||
|
session, ok := ws.sessions.GetHost()
|
||||||
|
if ok {
|
||||||
|
host = session.ID()
|
||||||
|
}
|
||||||
|
|
||||||
|
return types.Stats{
|
||||||
|
Connections: atomic.LoadUint32(&ws.conns),
|
||||||
|
Host: host,
|
||||||
|
Members: ws.sessions.Members(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WebSocketHandler) IsAdmin(password string) (bool, error) {
|
func (ws *WebSocketHandler) IsAdmin(password string) (bool, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user