Versions in this module Expand all Collapse all v1 v1.0.0 Dec 19, 2024 Changes in this version + func InitTCP(server *Server, addrs []string, accept int) (err error) + func InitWebsocket(server *Server, addrs []string, accept int) (err error) + func InitWebsocketWithTLS(server *Server, addrs []string, certFile, privateFile string, accept int) (err error) + func InitWhitelist(c *conf.Whitelist) (err error) + type Bucket struct + func NewBucket(c *conf.Bucket) (b *Bucket) + func (b *Bucket) Broadcast(p *protocol.Proto, op int32) + func (b *Bucket) BroadcastRoom(arg *pb.BroadcastRoomReq) + func (b *Bucket) ChangeRoom(nrid string, ch *Channel) (err error) + func (b *Bucket) Channel(key string) (ch *Channel) + func (b *Bucket) ChannelCount() int + func (b *Bucket) Del(dch *Channel) + func (b *Bucket) DelRoom(room *Room) + func (b *Bucket) IPCount() (res map[string]struct{}) + func (b *Bucket) Put(rid string, ch *Channel) (err error) + func (b *Bucket) Room(rid string) (room *Room) + func (b *Bucket) RoomCount() int + func (b *Bucket) Rooms() (res map[string]struct{}) + func (b *Bucket) RoomsCount() (res map[string]int32) + func (b *Bucket) UpRoomsCount(roomCountMap map[string]int32) + type Channel struct + CliProto Ring + IP string + Key string + Mid int64 + Next *Channel + Prev *Channel + Reader bufio.Reader + Room *Room + Writer bufio.Writer + func NewChannel(cli, svr int) *Channel + func (c *Channel) Close() + func (c *Channel) NeedPush(op int32) bool + func (c *Channel) Push(p *protocol.Proto) (err error) + func (c *Channel) Ready() *protocol.Proto + func (c *Channel) Signal() + func (c *Channel) UnWatch(accepts ...int32) + func (c *Channel) Watch(accepts ...int32) + type Ring struct + func NewRing(num int) *Ring + func (r *Ring) Get() (proto *protocol.Proto, err error) + func (r *Ring) GetAdv() + func (r *Ring) Init(num int) + func (r *Ring) Reset() + func (r *Ring) Set() (proto *protocol.Proto, err error) + func (r *Ring) SetAdv() + type Room struct + AllOnline int32 + ID string + Online int32 + func NewRoom(id string) (r *Room) + func (r *Room) Close() + func (r *Room) Del(ch *Channel) bool + func (r *Room) OnlineNum() int32 + func (r *Room) Push(p *protocol.Proto) + func (r *Room) Put(ch *Channel) (err error) + type Round struct + func NewRound(c *conf.Config) (r *Round) + func (r *Round) Reader(rn int) *bytes.Pool + func (r *Round) Timer(rn int) *time.Timer + func (r *Round) Writer(rn int) *bytes.Pool + type RoundOptions struct + ReadBuf int + ReadBufSize int + Reader int + Timer int + TimerSize int + WriteBuf int + WriteBufSize int + Writer int + type Server struct + func NewServer(c *conf.Config) *Server + func (s *Server) Bucket(subKey string) *Bucket + func (s *Server) Buckets() []*Bucket + func (s *Server) Close() (err error) + func (s *Server) Connect(c context.Context, p *protocol.Proto, cookie string) (mid int64, key, rid string, accepts []int32, heartbeat time.Duration, ...) + func (s *Server) Disconnect(c context.Context, mid int64, key string) (err error) + func (s *Server) Heartbeat(ctx context.Context, mid int64, key string) (err error) + func (s *Server) Operate(ctx context.Context, p *protocol.Proto, ch *Channel, b *Bucket) error + func (s *Server) RandServerHearbeat() time.Duration + func (s *Server) Receive(ctx context.Context, mid int64, p *protocol.Proto) (err error) + func (s *Server) RenewOnline(ctx context.Context, serverID string, roomCount map[string]int32) (allRoom map[string]int32, err error) + func (s *Server) ServeTCP(conn *net.TCPConn, rp, wp *bytes.Pool, tr *xtime.Timer) + func (s *Server) ServeWebsocket(conn net.Conn, rp, wp *bytes.Pool, tr *xtime.Timer) + type Whitelist struct + func (w *Whitelist) Contains(mid int64) (ok bool) + func (w *Whitelist) Printf(format string, v ...interface{})