mirror of
https://github.com/aler9/gortsplib
synced 2025-10-07 16:10:59 +08:00
new server structure
This commit is contained in:
@@ -9,8 +9,8 @@ import (
|
||||
var DefaultServerConf = ServerConf{}
|
||||
|
||||
// Serve starts a server on the given address.
|
||||
func Serve(address string, handler func(sc *ServerConn) ServerConnHandler) (*Server, error) {
|
||||
return DefaultServerConf.Serve(address, handler)
|
||||
func Serve(address string) (*Server, error) {
|
||||
return DefaultServerConf.Serve(address)
|
||||
}
|
||||
|
||||
// ServerConf allows to configure a Server.
|
||||
@@ -36,7 +36,7 @@ type ServerConf struct {
|
||||
}
|
||||
|
||||
// Serve starts a server on the given address.
|
||||
func (c ServerConf) Serve(address string, handler func(sc *ServerConn) ServerConnHandler) (*Server, error) {
|
||||
func (c ServerConf) Serve(address string) (*Server, error) {
|
||||
if c.ReadTimeout == 0 {
|
||||
c.ReadTimeout = 10 * time.Second
|
||||
}
|
||||
@@ -63,11 +63,7 @@ func (c ServerConf) Serve(address string, handler func(sc *ServerConn) ServerCon
|
||||
s := &Server{
|
||||
conf: c,
|
||||
listener: listener,
|
||||
handler: handler,
|
||||
}
|
||||
|
||||
s.wg.Add(1)
|
||||
go s.run()
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user