comet

package
v0.0.0-...-261bb52 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRoomIsDropped = errors.New("room is dropped")

ErrRoomIsDropped is err for room is dropped

View Source
var NoRoom = "NoRoom"

NoRoom is flag

Functions

func InitLogic

func InitLogic() (err error)

InitLogic is func for initial logic rpc client

func InitWebsocket

func InitWebsocket(s *Server, c *conf.WebsocketConf) (err error)

InitWebsocket is func to initial Websocket

Types

type Bucket

type Bucket struct {
	// contains filtered or unexported fields
}

Bucket is struct of Bucket

func NewBucket

func NewBucket(o *BucketOptions) (b *Bucket)

NewBucket is constructor of Bucket

func (*Bucket) BroadcastRoom

func (b *Bucket) BroadcastRoom(arg *RoomMsgArg)

BroadcastRoom is used to broadcast room

func (*Bucket) Channel

func (b *Bucket) Channel(key string) (ch *Channel)

Channel is func to get Channel from Bucket by key

func (*Bucket) PushRoom

func (b *Bucket) PushRoom(c chan *RoomMsgArg)

PushRoom is func to push room msg

func (*Bucket) Put

func (b *Bucket) Put(uid string, rid string, ch *Channel) (err error)

Put is func to add channel

func (*Bucket) Room

func (b *Bucket) Room(rid string) (room *Room)

Room get a room by rid.

type BucketOptions

type BucketOptions struct {
	ChannelSize   int
	RoomSize      int
	RoutineAmount uint64
	RoutineSize   int
}

BucketOptions is struct of Bucket Config

type Channel

type Channel struct {
	Room *Room

	Next *Channel
	Prev *Channel
	// contains filtered or unexported fields
}

Channel is struct of channel

func NewChannel

func NewChannel(svr int) *Channel

NewChannel is constructor of Channel

func (*Channel) Push

func (ch *Channel) Push(p *Proto) (err error)

Push is func to push msg

type ConnectArg

type ConnectArg struct {
	Auth     string
	RoomID   string
	ServerID string
}

ConnectArg is rpc connect arg

type ConnectReply

type ConnectReply struct {
	UID string
}

ConnectReply is struct for Connect reply

type DefaultOperator

type DefaultOperator struct{}

DefaultOperator is default operator

func (*DefaultOperator) Connect

func (operator *DefaultOperator) Connect(ctx context.Context, c *ConnectArg) (uid string, err error)

Connect is func to Connect

func (*DefaultOperator) Disconnect

func (operator *DefaultOperator) Disconnect(ctx context.Context, d *DisconnectArg) (err error)

Disconnect is func to Disconnect

type DisconnectArg

type DisconnectArg struct {
	RoomID string
	UID    string
}

DisconnectArg is rpc disconnect arg

type DisconnectReply

type DisconnectReply struct {
	Has bool
}

DisconnectReply is struct for Disconnect reply

type Operator

type Operator interface {
	Connect(context.Context, *ConnectArg) (string, error)
	Disconnect(context.Context, *DisconnectArg) error
}

Operator is interface for operation

type Proto

type Proto struct {
	Ver       int16           `json:"ver"`  // protocol version
	Operation int32           `json:"op"`   // operation for request
	Body      json.RawMessage `json:"body"` // binary body bytes(json.RawMessage is []byte)

}

Proto is struct for msg protocol

type Room

type Room struct {
	ID string // Room ID

	Online int
	// contains filtered or unexported fields
}

Room is struct of Room

func NewRoom

func NewRoom(ID string) *Room

NewRoom is constructor of Room

func (*Room) Del

func (r *Room) Del(ch *Channel) bool

Del is func to del channel from room

func (*Room) Push

func (r *Room) Push(p *Proto)

Push is func for room push msg

func (*Room) Put

func (r *Room) Put(ch *Channel) (err error)

Put is func for add channel

type RoomMsgArg

type RoomMsgArg struct {
	RoomID string
	P      Proto
}

RoomMsgArg is struct of room msg

type Server

type Server struct {
	Buckets []*Bucket // subKey bucket
	// contains filtered or unexported fields
}

Server is struct for Comet Server

var CurrentServer *Server

CurrentServer is var of current server

func NewServer

func NewServer(c *conf.Config) *Server

NewServer returns a new Server.

func (*Server) Bucket

func (s *Server) Bucket(ctx context.Context, subKey string) *Bucket

Bucket is func to location bucket use cityhash

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL