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)
- type Bucket
- func (b *Bucket) Broadcast(p *grpc.Proto, op int32, platform string)
- func (b *Bucket) BroadcastRoom(arg *grpc.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(p *model.Proto, cookie string) (mid int64, key, rid, platform string, accepts []int32, err error)
- func (s *Server) Disconnect(mid int64, key string) (err error)
- func (s *Server) Heartbeat(mid int64, key string) (err error)
- func (s *Server) NextKey() string
- func (s *Server) Operate(p *model.Proto, ch *Channel, b *Bucket) (err error)
- func (s *Server) RandServerHearbeat() time.Duration
- func (s *Server) RenewOnline(serverID string, rommCount map[string]int32) (allRoom map[string]int32, err error)
- func (s *Server) Report(mid int64, room string, p *model.Proto) (rp *model.Proto, 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)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitWebsocket ¶
InitWebsocket listen all tcp.bind and start accept connections.
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket is a channel holder.
func (*Bucket) BroadcastRoom ¶
func (b *Bucket) BroadcastRoom(arg *grpc.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 Platform string // contains filtered or unexported fields }
Channel used by message pusher send msg to write goroutine.
type Room ¶
type Room struct { ID string Online int32 // dirty read is ok AllOnline int32 // contains filtered or unexported fields }
Room is a room.
type Round ¶
type Round struct {
// contains filtered or unexported fields
}
Round userd 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 .
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server .
func (*Server) Connect ¶
func (s *Server) Connect(p *model.Proto, cookie string) (mid int64, key, rid, platform string, accepts []int32, err error)
Connect .
func (*Server) Disconnect ¶
Disconnect .
func (*Server) RandServerHearbeat ¶
RandServerHearbeat rand server heartbeat.
func (*Server) RenewOnline ¶
func (s *Server) RenewOnline(serverID string, rommCount map[string]int32) (allRoom map[string]int32, err error)
RenewOnline .
Source Files ¶
Click to show internal directories.
Click to hide internal directories.