Documentation ¶
Index ¶
- Variables
- func LogHeadByConnType(connType ConnType) string
- type AuthParams
- type Channel
- func (c *Channel) CleanPath1()
- func (c *Channel) CleanPath2()
- func (c *Channel) CleanPath3()
- func (c *Channel) Push(p *protocol.Proto) (err error)
- func (c *Channel) SendFinish(logHead string)
- func (c *Channel) SendReady()
- func (c *Channel) SetWebSocketConnReaderWriter(wsConn *websocket.Conn)
- func (c *Channel) Waiting() *protocol.Proto
- type CleanPath
- type ConnComponent
- type ConnType
- type Ring
- type Room
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrRingEmpty = errors.New("ring buffer empty") ErrRingFull = errors.New("ring buffer full") )
Functions ¶
func LogHeadByConnType ¶
Types ¶
type AuthParams ¶
type Channel ¶
type Channel struct { ConnComponent // the Room that Channel(User) is in Room *Room Next *Channel Prev *Channel // use bufio to reuse buffer Writer *bufio.Writer Reader *bufio.Reader ConnReadWriter protocol.ConnReadWriter // user info UserInfo *UserInfo // use to get proto,reduce GC ProtoAllocator Ring // contains filtered or unexported fields }
Channel 每一个Channel代表一个长连接
func NewChannel ¶
func NewChannel(conf *conf.Config, conn *net.TCPConn, traceId int64, connType ConnType, readerPool, writerPool *bytes.Pool, timerPool *newtimer.Timer) *Channel
NewChannel new a channel.
func (*Channel) CleanPath1 ¶
func (c *Channel) CleanPath1()
func (*Channel) SetWebSocketConnReaderWriter ¶
type ConnComponent ¶
type ConnComponent struct { TraceId int64 ConnType ConnType // Connection(fd) Conn *net.TCPConn WsConn *websocket.Conn // 分配buffer池子 WriterPool *bytes.Pool ReaderPool *bytes.Pool // 分配定时器的池子 TimerPool *newtimer.Timer // 从池子分配得到Timer Trd *newtimer.TimerData // 心跳相关 LastHb time.Time // 上一次接收到心跳的时间 HbExpire time.Duration // 心跳超时的时间 HbInterval time.Duration // 心跳续约频率 // contains filtered or unexported fields }
ConnComponent 每一条连接需要用到的组件
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
Ring use to get proto,reduce GC Every User Has A Channel and Every Channel Has a Ring
func (*Ring) GetProtoForRead ¶
GetProtoForRead 获取一个Proto(用于读取的Proto) 后续通过 Ring.AdvReadPointer 推进读指针
func (*Ring) GetProtoForWrite ¶
GetProtoForWrite 获取一个Proto(用于写入的Proto) 后续通过 Ring.AdvWritePointer 推进写指针
type Room ¶
type Room struct { Id string Online int32 // 单台机器,单个房间的在线人数:dirty read is ok AllOnline int32 // 单台机器,所有房间的在线人数 // contains filtered or unexported fields }
Room is a room and store channel room info.
func (*Room) PutChannel ¶
PutChannel 把Channel放到房间中 insert to the head of the linklist
func (*Room) SendToAllChan ¶
SendToAllChan 把proto推送到房间中的所有Channel
Click to show internal directories.
Click to hide internal directories.