Documentation ¶
Index ¶
- Constants
- Variables
- func SetLogger(newLogger zerolog.Logger)
- type Dialer
- type FrameConn
- func (f *FrameConn) Close() error
- func (f *FrameConn) LocalAddr() net.Addr
- func (f *FrameConn) Read(b []byte) (int, error)
- func (f *FrameConn) RemoteAddr() net.Addr
- func (f *FrameConn) SetDeadline(t time.Time) error
- func (f *FrameConn) SetReadDeadline(t time.Time) error
- func (f *FrameConn) SetWriteDeadline(t time.Time) error
- func (f *FrameConn) Write(dat []byte) (int, error)
- type ListenConfig
- type Listener
- type Pipe
- type PipeSocket
- type SimSocket
- type Socket
- type TcpDialer
- type TcpListener
- type WebRtcDialer
- type WebsocketDialer
- type WebsocketListener
Constants ¶
const MaxRecvMsgSize = 64 * 1024 // 8 KB // TODO! - this is arbitrary. Need a better way to manage message sizes. I'm just setting this to be big enough for my mmo
TODO - Ensure sent messages remain under this Calculation: 1460 Byte = 1500 Byte - 20 Byte IP Header - 20 Byte TCP Header const MaxMsgSize = 1460 // bytes
Variables ¶
var ErrClosed = errors.New("socket closed") // Indicates that the socket is closed. Currently if you get this error then it means the socket will never receive or send again!
var ErrDisconnected = errors.New("socket disconnected")
var ErrNetwork = errors.New("network error")
Functions ¶
Types ¶
type FrameConn ¶
type FrameConn struct {
// contains filtered or unexported fields
}
func NewFrameConn ¶
func (*FrameConn) RemoteAddr ¶
type ListenConfig ¶
type ListenConfig struct { Url string // Note: We only use the [scheme]://[host] portion of this TlsConfig *tls.Config HttpServer *http.Server // TODO - For Websockets only, maybe split up? - Note we have to wrap their Handler with our own handler! OriginPatterns []string IceServers []string // contains filtered or unexported fields }
-------------------------------------------------------------------------------- - Listener -------------------------------------------------------------------------------- For listening for sockets
func (*ListenConfig) Listen ¶
func (c *ListenConfig) Listen() (Listener, error)
type PipeSocket ¶
type PipeSocket struct {
// contains filtered or unexported fields
}
-------------------------------------------------------------------------------- - Transport based sockets --------------------------------------------------------------------------------
func (*PipeSocket) Close ¶
func (s *PipeSocket) Close() error
func (*PipeSocket) Closed ¶
func (s *PipeSocket) Closed() bool
func (*PipeSocket) Connected ¶
func (s *PipeSocket) Connected() bool
func (*PipeSocket) ReadEgress ¶
func (s *PipeSocket) ReadEgress() int64
func (*PipeSocket) ReadIngress ¶
func (s *PipeSocket) ReadIngress() int64
type SimSocket ¶
type SimSocket struct { Socket Packetloss float64 // This is the probability that the packet will be lossed for every send/recv MinDelay time.Duration // This is the min delay added to every packet sent or recved MaxDelay time.Duration // This is the max delay added to every packet sent or recved // contains filtered or unexported fields }
-------------------------------------------------------------------------------- - Packetloss code --------------------------------------------------------------------------------
func NewSimSocket ¶
type Socket ¶
type Socket interface { Read([]byte) (int, error) Write([]byte) (int, error) Close() error Connected() bool Closed() bool // Reads and clears the number egress bytes ReadEgress() int64 // Reads and clears the number ingress bytes ReadIngress() int64 }
func NewDialSocket ¶
-------------------------------------------------------------------------------- - Dialer --------------------------------------------------------------------------------
type TcpListener ¶
type TcpListener struct {
// contains filtered or unexported fields
}
func (*TcpListener) Accept ¶
func (l *TcpListener) Accept() (Socket, error)
func (*TcpListener) Addr ¶
func (l *TcpListener) Addr() net.Addr
func (*TcpListener) Close ¶
func (l *TcpListener) Close() error
type WebRtcDialer ¶
type WebRtcDialer struct { Url string TlsConfig *tls.Config Ordered bool IceServers []string WebsocketFallback bool }
func (WebRtcDialer) DialPipe ¶
func (d WebRtcDialer) DialPipe() (Pipe, error)
type WebsocketDialer ¶
func (WebsocketDialer) DialPipe ¶
func (d WebsocketDialer) DialPipe() (Pipe, error)
type WebsocketListener ¶
type WebsocketListener struct {
// contains filtered or unexported fields
}
-------------------------------------------------------------------------------- - Listener --------------------------------------------------------------------------------
func (*WebsocketListener) Accept ¶
func (l *WebsocketListener) Accept() (Socket, error)
func (*WebsocketListener) Addr ¶
func (l *WebsocketListener) Addr() net.Addr
func (*WebsocketListener) Close ¶
func (l *WebsocketListener) Close() error
func (*WebsocketListener) ServeHTTP ¶
func (l *WebsocketListener) ServeHTTP(w http.ResponseWriter, r *http.Request)