Documentation ¶
Index ¶
- 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
- 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
- type Ring
- type Room
- type Round
- type RoundOptions
- type 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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitWebsocket ¶
InitWebsocket listen all tcp.bind and start accept connections.
func InitWebsocketWithTLS ¶
func InitWebsocketWithTLS(server *Server, addrs []string, certFile, privateFile string, accept int) (err error)
InitWebsocketWithTLS init websocket with tls.
func InitWhitelist ¶
InitWhitelist a whitelist struct.
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket is a channel holder.
func (*Bucket) BroadcastRoom ¶
func (b *Bucket) BroadcastRoom(arg *pb.BroadcastRoomReq)
BroadcastRoom broadcast a message to specified room
func (*Bucket) ChangeRoom ¶
ChangeRoom change ro room
func (*Bucket) ChannelCount ¶
ChannelCount channel count in the bucket
func (*Bucket) RoomsCount ¶
RoomsCount get all room id where online number > 0.
func (*Bucket) UpRoomsCount ¶
UpRoomsCount update all room count
type Channel ¶
type Channel struct { Room *Room CliProto Ring Writer bufio.Writer Reader bufio.Reader Next *Channel Prev *Channel Mid int64 Key string IP string // contains filtered or unexported fields }
Channel used by message pusher send msg to write goroutine.
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
Ring ring proto buffer.
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.
type Round ¶
type Round struct {
// contains filtered or unexported fields
}
Round used for connection round-robin get a reader/writer/timer for split big lock.
type RoundOptions ¶
type RoundOptions struct { Timer int TimerSize int Reader int ReadBuf int ReadBufSize int Writer int WriteBuf int WriteBufSize int }
RoundOptions round options.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is comet server.
func (*Server) Connect ¶
func (s *Server) Connect(c context.Context, p *protocol.Proto, cookie string) (mid int64, key, rid string, accepts []int32, heartbeat time.Duration, err error)
Connect connected a connection.
func (*Server) Disconnect ¶
Disconnect disconnected a connection.
func (*Server) RandServerHearbeat ¶
RandServerHearbeat rand server heartbeat.
func (*Server) RenewOnline ¶
func (s *Server) RenewOnline(ctx context.Context, serverID string, roomCount map[string]int32) (allRoom map[string]int32, err error)
RenewOnline renew room online.