Documentation ¶
Index ¶
- Constants
- Variables
- func ReadUserIP(r *http.Request) *net.TCPAddr
- type Acceptor
- type AcceptorConfig
- type AcceptorConn
- type AcceptorGroupConfig
- type ConnInfo
- type MiddlewareFunc
- type WSAcceptor
- type WSConn
- func (c *WSConn) Close() error
- func (c *WSConn) GetInfo() *ConnInfo
- func (c *WSConn) GetNextMessage() (b []byte, err error)
- func (c *WSConn) IsClosed() bool
- func (c *WSConn) LocalAddr() net.Addr
- func (c *WSConn) Read(b []byte) (int, error)
- func (c *WSConn) RemoteAddr() net.Addr
- func (c *WSConn) SetCloseHandler(f func())
- func (c *WSConn) SetDeadline(t time.Time) error
- func (c *WSConn) SetReadDeadline(t time.Time) error
- func (c *WSConn) SetWriteDeadline(t time.Time) error
- func (c *WSConn) Write(b []byte) (int, error)
- type WebRTCAcceptor
- func (w *WebRTCAcceptor) GetAddr() string
- func (w *WebRTCAcceptor) GetConfig() *AcceptorConfig
- func (w *WebRTCAcceptor) GetConnChan() chan AcceptorConn
- func (w *WebRTCAcceptor) GetName() string
- func (w *WebRTCAcceptor) GetType() string
- func (w *WebRTCAcceptor) ListenAndServe()
- func (w *WebRTCAcceptor) Stop()
- type WebRTCConn
- func (c *WebRTCConn) Close() error
- func (c *WebRTCConn) GetInfo() *ConnInfo
- func (c *WebRTCConn) GetNextMessage() (b []byte, err error)
- func (c *WebRTCConn) IsClosed() bool
- func (c *WebRTCConn) LocalAddr() net.Addr
- func (c *WebRTCConn) Read(b []byte) (int, error)
- func (c *WebRTCConn) RemoteAddr() net.Addr
- func (c *WebRTCConn) SetCloseHandler(f func())
- func (c *WebRTCConn) SetDeadline(t time.Time) error
- func (c *WebRTCConn) SetReadDeadline(t time.Time) error
- func (c *WebRTCConn) SetWriteDeadline(t time.Time) error
- func (c *WebRTCConn) Write(b []byte) (int, error)
Constants ¶
View Source
const ( ConnStatusStart int32 ConnStatusClosed )
View Source
const ( StatusWorking int32 StatusClosed )
Variables ¶
View Source
var ( ACCEPTOR_TYPE_WS = "websockets" ACCEPTOR_TYPE_WEBRTC = "webrtc" ErrMessageRateLimit = errors.New("message rate limit") )
Functions ¶
Types ¶
type Acceptor ¶
type Acceptor interface { GetConfig() *AcceptorConfig // get the config ListenAndServe() // listen and serve Stop() // stop the acceptor GetConnChan() chan AcceptorConn // get the conn channel GetAddr() string // get the addr GetName() string // get the name GetType() string // get the type }
Acceptor type interface
type AcceptorConfig ¶ added in v0.2.1
type AcceptorConfig struct { Name string // the name of the acceptor Groups []*AcceptorGroupConfig // the groups of the acceptor Type string // the type of the acceptor HttpPort int UdpPort int }
type AcceptorConn ¶
type AcceptorConn interface { GetNextMessage() (b []byte, err error) // get the next message GetInfo() *ConnInfo // get the conn info SetCloseHandler(func()) // set the close callback IsClosed() bool // is conn closed net.Conn // Conn }
AcceptorConn interface
type AcceptorGroupConfig ¶
type ConnInfo ¶
type ConnInfo struct { AcceptorType string // the type of the acceptor AcceptorName string // the name of the acceptor AcceptorGroup string // the group of the acceptor Ordered bool // whether the message is ordered, only for webrtc BucketFillInterval time.Duration // the interval of the bucket fill BucketCapacity int64 // the capacity of the bucket }
type WSAcceptor ¶
type WSAcceptor struct {
// contains filtered or unexported fields
}
func NewWSAcceptor ¶ added in v0.2.1
func NewWSAcceptor(config *AcceptorConfig) *WSAcceptor
func (*WSAcceptor) GetAddr ¶
func (w *WSAcceptor) GetAddr() string
func (*WSAcceptor) GetConfig ¶ added in v0.1.2
func (w *WSAcceptor) GetConfig() *AcceptorConfig
func (*WSAcceptor) GetConnChan ¶
func (w *WSAcceptor) GetConnChan() chan AcceptorConn
func (*WSAcceptor) GetName ¶
func (w *WSAcceptor) GetName() string
func (*WSAcceptor) GetType ¶
func (w *WSAcceptor) GetType() string
func (*WSAcceptor) ListenAndServe ¶
func (w *WSAcceptor) ListenAndServe()
func (*WSAcceptor) Stop ¶
func (w *WSAcceptor) Stop()
type WSConn ¶
type WSConn struct { MaxMessagesInSecond uint // contains filtered or unexported fields }
func (*WSConn) GetNextMessage ¶
GetNextMessage reads the next message available in the stream
func (*WSConn) RemoteAddr ¶
func (*WSConn) SetCloseHandler ¶
func (c *WSConn) SetCloseHandler(f func())
type WebRTCAcceptor ¶
type WebRTCAcceptor struct {
// contains filtered or unexported fields
}
WebRTCAcceptor accept the webrtc data channel connection
func NewWebRTCAcceptor ¶
func NewWebRTCAcceptor(config *AcceptorConfig) *WebRTCAcceptor
func (*WebRTCAcceptor) GetAddr ¶
func (w *WebRTCAcceptor) GetAddr() string
func (*WebRTCAcceptor) GetConfig ¶ added in v0.1.2
func (w *WebRTCAcceptor) GetConfig() *AcceptorConfig
func (*WebRTCAcceptor) GetConnChan ¶
func (w *WebRTCAcceptor) GetConnChan() chan AcceptorConn
func (*WebRTCAcceptor) GetName ¶
func (w *WebRTCAcceptor) GetName() string
func (*WebRTCAcceptor) GetType ¶
func (w *WebRTCAcceptor) GetType() string
func (*WebRTCAcceptor) ListenAndServe ¶
func (w *WebRTCAcceptor) ListenAndServe()
func (*WebRTCAcceptor) Stop ¶
func (w *WebRTCAcceptor) Stop()
type WebRTCConn ¶
type WebRTCConn struct {
// contains filtered or unexported fields
}
func NewWebRTCConn ¶
func NewWebRTCConn(conn *webrtc.PeerConnection, dataChannel *webrtc.DataChannel, rw datachannel.ReadWriteCloser, info *ConnInfo) *WebRTCConn
func (*WebRTCConn) Close ¶
func (c *WebRTCConn) Close() error
func (*WebRTCConn) GetInfo ¶
func (c *WebRTCConn) GetInfo() *ConnInfo
func (*WebRTCConn) GetNextMessage ¶
func (c *WebRTCConn) GetNextMessage() (b []byte, err error)
func (*WebRTCConn) IsClosed ¶
func (c *WebRTCConn) IsClosed() bool
func (*WebRTCConn) LocalAddr ¶
func (c *WebRTCConn) LocalAddr() net.Addr
func (*WebRTCConn) RemoteAddr ¶
func (c *WebRTCConn) RemoteAddr() net.Addr
func (*WebRTCConn) SetCloseHandler ¶
func (c *WebRTCConn) SetCloseHandler(f func())
func (*WebRTCConn) SetDeadline ¶
func (c *WebRTCConn) SetDeadline(t time.Time) error
func (*WebRTCConn) SetReadDeadline ¶
func (c *WebRTCConn) SetReadDeadline(t time.Time) error
func (*WebRTCConn) SetWriteDeadline ¶
func (c *WebRTCConn) SetWriteDeadline(t time.Time) error
Click to show internal directories.
Click to hide internal directories.