Documentation ¶
Index ¶
- Constants
- Variables
- func CheckType(name string) error
- func DialTimeout()
- type Channel
- type ChannelFactory
- type Client
- func (c *Client) AddHost(host string, port int)
- func (c *Client) Close()
- func (c *Client) CloseChannel(name string) error
- func (c *Client) GetFlow() *flow.Flow
- func (c *Client) GetRunningChans() int
- func (c *Client) GetSpeedInfo() *statistic.SpeedInfo
- func (c *Client) GetStats() string
- func (c *Client) GetUsefulChan() []Channel
- func (c *Client) MakeNewChannel(slot Slot) error
- func (c *Client) Ports() []int
- func (c *Client) Run()
- func (c *Client) UpdateRemoteAddrs(host string, ports []int)
- type ClientDelegate
- type Group
- func (g *Group) AddWithAutoRemove(c Channel)
- func (g *Group) ChannelCount() int
- func (g *Group) Close()
- func (g *Group) CloseChannel(name string) error
- func (g *Group) GetSpeed() *statistic.SpeedInfo
- func (g *Group) GetStatsInfo() string
- func (g *Group) GetUseful() []int
- func (g *Group) GetUsefulChan() []Channel
- func (g *Group) Run()
- func (g *Group) Send(p []*packet.Packet)
- type Header
- type HttpChan
- func (h *HttpChan) AddOnClose(f func())
- func (h *HttpChan) ChanWrite() packet.SendChan
- func (h *HttpChan) Close()
- func (h *HttpChan) GetSpeed() *statistic.SpeedInfo
- func (h *HttpChan) GetStat() *statistic.HeartBeat
- func (h *HttpChan) GetUserId() (int, error)
- func (h *HttpChan) HeartBeatClean(err error)
- func (h *HttpChan) IsSvrModeAndUninit() bool
- func (h *HttpChan) Latency() (time.Duration, time.Duration)
- func (h *HttpChan) Name() string
- func (h *HttpChan) ReadL2(b *bufio.Reader) (*packet.PacketL2, error)
- func (h *HttpChan) Run()
- func (h *HttpChan) WriteL2(p *packet.PacketL2) []byte
- type HttpChanFactory
- func (HttpChanFactory) DialTimeout(host string, timeout time.Duration) (net.Conn, error)
- func (HttpChanFactory) Listen(*flow.Flow) (net.Listener, error)
- func (HttpChanFactory) NewClient(f *flow.Flow, s *packet.Session, c net.Conn, o packet.SendChan) Channel
- func (HttpChanFactory) NewServer(f *flow.Flow, s *packet.Session, c net.Conn, d SvrInitDelegate) Channel
- type KcpChanFactory
- type Listener
- type ListenerGroup
- type Server
- type SimpleReq
- type Slot
- type SvrAuthDelegate
- type SvrDelegate
- type SvrInitDelegate
- type TcpChan
- func (c *TcpChan) AddOnClose(f func())
- func (c *TcpChan) ChanWrite() packet.SendChan
- func (c *TcpChan) Close()
- func (c *TcpChan) GetSpeed() *statistic.SpeedInfo
- func (c *TcpChan) GetStat() *statistic.HeartBeat
- func (c *TcpChan) GetUserId() (int, error)
- func (c *TcpChan) HeartBeatClean(err error)
- func (c *TcpChan) IsSvrModeAndUninit() bool
- func (c *TcpChan) Latency() (latency, lastCommit time.Duration)
- func (c *TcpChan) Name() string
- func (c *TcpChan) ReadL2(r *bufio.Reader) (*packet.PacketL2, error)
- func (c *TcpChan) Run()
- func (c *TcpChan) WriteL2(p *packet.PacketL2) []byte
- type TcpChanFactory
- func (TcpChanFactory) DialTimeout(host string, timeout time.Duration) (net.Conn, error)
- func (TcpChanFactory) Listen(*flow.Flow) (net.Listener, error)
- func (TcpChanFactory) NewClient(f *flow.Flow, session *packet.Session, conn net.Conn, out packet.SendChan) Channel
- func (TcpChanFactory) NewServer(f *flow.Flow, session *packet.Session, conn net.Conn, delegate SvrInitDelegate) Channel
- type UDPConn
- func (u *UDPConn) Close() error
- func (u *UDPConn) LocalAddr() net.Addr
- func (u *UDPConn) Read(b []byte) (int, error)
- func (u *UDPConn) RemoteAddr() net.Addr
- func (u *UDPConn) SetDeadline(d time.Time) error
- func (u *UDPConn) SetReadDeadline(d time.Time) error
- func (u *UDPConn) SetWriteDeadline(d time.Time) error
- func (u *UDPConn) Write(b []byte) (int, error)
- func (u *UDPConn) WriteChan() chan []byte
- type UDPListener
- type UdpChanFactory
- func (UdpChanFactory) DialTimeout(host string, timeout time.Duration) (net.Conn, error)
- func (u *UdpChanFactory) Listen(f *flow.Flow) (net.Listener, error)
- func (UdpChanFactory) NewClient(f *flow.Flow, session *packet.Session, conn net.Conn, out packet.SendChan) Channel
- func (UdpChanFactory) NewServer(f *flow.Flow, session *packet.Session, conn net.Conn, delegate SvrInitDelegate) Channel
Constants ¶
View Source
const (
ChanCount = 1
)
Variables ¶
View Source
var ( HttpKeyIV = "X-Log" HttpKeyUserId = "X-Host-ID" HttpKeyChecksum = "X-MD5" )
View Source
var ( ErrInvalidUserId = logex.Define("invalid user id") ErrUnexpectedPacketType = logex.Define("unexpected packet type") )
Functions ¶
func DialTimeout ¶
func DialTimeout()
Types ¶
type Channel ¶
type Channel interface { Close() Name() string GetStat() *statistic.HeartBeat Latency() (time.Duration, time.Duration) GetUserId() (int, error) AddOnClose(func()) GetSpeed() *statistic.SpeedInfo ChanWrite() packet.SendChan Run() ReadL2(*bufio.Reader) (*packet.PacketL2, error) WriteL2(*packet.PacketL2) []byte }
func NewTcpChanClient ¶
func NewTcpChanServer ¶
type ChannelFactory ¶
type ChannelFactory interface { NewClient(*flow.Flow, *packet.Session, net.Conn, packet.SendChan) Channel NewServer(*flow.Flow, *packet.Session, net.Conn, SvrInitDelegate) Channel Listen(f *flow.Flow) (net.Listener, error) DialTimeout(host string, timeout time.Duration) (net.Conn, error) }
func GetChannelType ¶
func GetChannelType(name string) ChannelFactory
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(f *flow.Flow, s *packet.Session, delegate ClientDelegate, chanTyp string, toDC packet.RecvChan, fromDC packet.SendChan) (*Client, error)
out is which datachannel can write for all of channel share on fromDC, and have their owned toDC client receive all packet from toDC and try to send them
func (*Client) CloseChannel ¶
func (*Client) GetRunningChans ¶
func (*Client) GetSpeedInfo ¶
func (*Client) GetUsefulChan ¶
func (*Client) MakeNewChannel ¶
func (*Client) UpdateRemoteAddrs ¶
type ClientDelegate ¶
type ClientDelegate interface { OnAllBackoff(*Client) OnLinkRefused() }
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Channel can't close by Group
func (*Group) AddWithAutoRemove ¶
func (*Group) ChannelCount ¶
func (*Group) CloseChannel ¶
func (*Group) GetStatsInfo ¶
func (*Group) GetUsefulChan ¶
type HttpChan ¶
type HttpChan struct {
// contains filtered or unexported fields
}
to simulate http interactive
func NewHttpChanClient ¶
func NewHttpChanServer ¶
func (*HttpChan) AddOnClose ¶
func (h *HttpChan) AddOnClose(f func())
func (*HttpChan) HeartBeatClean ¶
func (*HttpChan) IsSvrModeAndUninit ¶
type HttpChanFactory ¶
type HttpChanFactory struct{}
func (HttpChanFactory) DialTimeout ¶
type KcpChanFactory ¶
type KcpChanFactory struct{}
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
add self monitor
func NewListener ¶
func NewListener(f *flow.Flow, d SvrDelegate, chanFactory ChannelFactory, c func()) (*Listener, error)
type ListenerGroup ¶
type ListenerGroup struct {
// contains filtered or unexported fields
}
func NewListenerGroup ¶
func NewListenerGroup(f *flow.Flow, chanType string, delegate SvrDelegate) *ListenerGroup
server communicate with channel
func (*ListenerGroup) Close ¶
func (s *ListenerGroup) Close()
func (*ListenerGroup) GetAllDataChannel ¶
func (s *ListenerGroup) GetAllDataChannel() []int
func (*ListenerGroup) GetDataChannel ¶
func (s *ListenerGroup) GetDataChannel() int
func (*ListenerGroup) Run ¶
func (s *ListenerGroup) Run(n int)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server side for operate datachannel for all user
func (*Server) AddChannel ¶
type SimpleReq ¶
type SimpleReq struct { Header Header Body io.ReadCloser }
type SvrAuthDelegate ¶
type SvrDelegate ¶
type SvrInitDelegate ¶
type TcpChan ¶
type TcpChan struct {
// contains filtered or unexported fields
}
func (*TcpChan) AddOnClose ¶
func (c *TcpChan) AddOnClose(f func())
func (*TcpChan) HeartBeatClean ¶
func (*TcpChan) IsSvrModeAndUninit ¶
type TcpChanFactory ¶
type TcpChanFactory struct{}
func (TcpChanFactory) DialTimeout ¶
type UDPConn ¶
type UDPConn struct {
// contains filtered or unexported fields
}
func NewUDPConn ¶
func (*UDPConn) RemoteAddr ¶
type UDPListener ¶
type UDPListener struct {
// contains filtered or unexported fields
}
func NewUDPListener ¶
func NewUDPListener(f *flow.Flow, conn *net.UDPConn) *UDPListener
func (*UDPListener) Addr ¶
func (u *UDPListener) Addr() net.Addr
func (*UDPListener) ClientClose ¶
func (u *UDPListener) ClientClose(addr *net.UDPAddr)
func (*UDPListener) Close ¶
func (u *UDPListener) Close() error
func (*UDPListener) WriteToUDP ¶
type UdpChanFactory ¶
type UdpChanFactory struct {
// contains filtered or unexported fields
}
func NewUdpChanFactory ¶
func NewUdpChanFactory() *UdpChanFactory
func (UdpChanFactory) DialTimeout ¶
Click to show internal directories.
Click to hide internal directories.