Documentation ¶
Index ¶
- Variables
- func InitTCP(server *Server, addrs []string, accept int) (err error)
- func InitTCPV1(server *Server, addrs []string, accept int) (err error)
- func InitWebsocket(server *Server, addrs []string, accept int) (err error)
- func InitWebsocketV1(s *Server, addrs []string, accept int) (err error)
- func InitWebsocketWithTLS(server *Server, addrs []string, certFile, privateFile string, accept int) (err error)
- func InitWebsocketWithTLSV1(s *Server, addrs []string, certFile, privateFile string, accept int) (err error)
- func InitWhitelist(c *conf.Whitelist) (err error)
- type Bucket
- func (b *Bucket) Broadcast(p *model.Proto, op int32, platform string)
- func (b *Bucket) BroadcastRoom(arg ProtoRoom)
- 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) RoomIPCount() (res map[string]struct{})
- 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 NoAuthParam
- type ProtoRoom
- type Report
- 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(ctx context.Context, p *model.Proto, cookie string) (mid int64, key, rid, platform string, accepts []int32, err error)
- func (s *Server) Disconnect(ctx context.Context, mid int64, key string) (err error)
- func (s *Server) Heartbeat(ctx context.Context, mid int64, key string) (err error)
- func (s *Server) NextKey() string
- func (s *Server) NoAuth(ver int16, token []byte, ip string) (userID int64, roomID, key string, rpt *Report, err error)
- func (s *Server) Operate(p *model.Proto, ch *Channel, b *Bucket) error
- func (s *Server) RandServerHearbeat() time.Duration
- func (s *Server) RenewOnline(ctx context.Context, serverID string, shard int32, rommCount map[string]int32) (allRoom map[string]int32, err error)
- func (s *Server) Report(mid int64, proto *model.Proto) (rp *model.Proto, err error)
- func (s *Server) ServeTCP(conn *net.TCPConn, rp, wp *bytes.Pool, tr *itime.Timer)
- func (s *Server) ServeWebsocket(conn net.Conn, rp, wp *bytes.Pool, tr *itime.Timer)
- type Whitelist
Constants ¶
This section is empty.
Variables ¶
var ( // server ErrHandshake = errors.New("handshake failed") ErrOperation = errors.New("request operation not valid") // ring ErrRingEmpty = errors.New("ring buffer empty") ErrRingFull = errors.New("ring buffer full") // timer ErrTimerFull = errors.New("timer full") ErrTimerEmpty = errors.New("timer empty") ErrTimerNoItem = errors.New("timer item not exist") // channel ErrPushMsgArg = errors.New("rpc pushmsg arg error") ErrPushMsgsArg = errors.New("rpc pushmsgs arg error") ErrMPushMsgArg = errors.New("rpc mpushmsg arg error") ErrMPushMsgsArg = errors.New("rpc mpushmsgs arg error") // bucket ErrBroadCastArg = errors.New("rpc broadcast arg error") ErrBroadCastRoomArg = errors.New("rpc broadcast room arg error") // room ErrRoomDroped = errors.New("room droped") // rpc ErrLogic = errors.New("logic rpc is not available") )
.
Functions ¶
func InitWebsocket ¶
InitWebsocket listen all tcp.bind and start accept connections.
func InitWebsocketV1 ¶
InitWebsocketV1 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 InitWebsocketWithTLSV1 ¶
func InitWebsocketWithTLSV1(s *Server, addrs []string, certFile, privateFile string, accept int) (err error)
InitWebsocketWithTLSV1 .
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 ¶
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) RoomIPCount ¶
RoomIPCount get ip count.
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 V1 bool // contains filtered or unexported fields }
Channel used by message pusher send msg to write goroutine.
type NoAuthParam ¶
type NoAuthParam struct { Key string `json:"key,omitempty"` Aid int64 `json:"aid,omitempty"` RoomID int64 `json:"roomid,omitempty"` UserID int64 `json:"uid,omitempty"` From int64 `json:"from,omitempty"` }
NoAuthParam .
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(ctx context.Context, p *model.Proto, cookie string) (mid int64, key, rid, platform string, accepts []int32, err error)
Connect .
func (*Server) Disconnect ¶
Disconnect .
func (*Server) NoAuth ¶
func (s *Server) NoAuth(ver int16, token []byte, ip string) (userID int64, roomID, key string, rpt *Report, err error)
NoAuth .
func (*Server) RandServerHearbeat ¶
RandServerHearbeat rand server heartbeat.
func (*Server) RenewOnline ¶
func (s *Server) RenewOnline(ctx context.Context, serverID string, shard int32, rommCount map[string]int32) (allRoom map[string]int32, err error)
RenewOnline .