mirror of
https://github.com/aler9/gortsplib
synced 2025-10-19 21:44:51 +08:00
server: allow to associate user data to sessions (#50)
This commit is contained in:
@@ -163,6 +163,7 @@ type ServerSession struct {
|
||||
|
||||
ctx context.Context
|
||||
ctxCancel func()
|
||||
userData interface{}
|
||||
conns map[*ServerConn]struct{}
|
||||
state ServerSessionState
|
||||
setuppedTracks map[int]*ServerSessionSetuppedTrack
|
||||
@@ -242,6 +243,16 @@ func (ss *ServerSession) AnnouncedTracks() Tracks {
|
||||
return ss.announcedTracks
|
||||
}
|
||||
|
||||
// SetUserData sets some user data associated to the session.
|
||||
func (ss *ServerSession) SetUserData(v interface{}) {
|
||||
ss.userData = v
|
||||
}
|
||||
|
||||
// UserData returns some user data associated to the session.
|
||||
func (ss *ServerSession) UserData() interface{} {
|
||||
return ss.userData
|
||||
}
|
||||
|
||||
func (ss *ServerSession) checkState(allowed map[ServerSessionState]struct{}) error {
|
||||
if _, ok := allowed[ss.state]; ok {
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user