connect

package
v0.0.0-...-4e35581 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const NoRoom = -1

NoRoom ...

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

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

Bucket ...

func NewBucket

func NewBucket(bucketOptions BucketOptions) (b *Bucket)

NewBucket ...

func (*Bucket) BroadcastRoom

func (b *Bucket) BroadcastRoom(pushRoomMsgReq *proto.PushRoomMsgRequest)

BroadcastRoom ...

func (*Bucket) Channel

func (b *Bucket) Channel(userID int) (ch *Channel)

Channel ...

func (*Bucket) DeleteChannel

func (b *Bucket) DeleteChannel(ch *Channel)

DeleteChannel 从 bucket 中删除一个用户会话

func (*Bucket) PushRoom

func (b *Bucket) PushRoom(ch chan *proto.PushRoomMsgRequest)

PushRoom 向一个房间推送消息就是想一个房间中的所用用户推送消息

func (*Bucket) Put

func (b *Bucket) Put(userID int, roomID int, ch *Channel) (err error)

Put 通过 userID 和 roomID 把用户连接会话放入 bucket 中

func (*Bucket) Room

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

Room 通过房间id获取房间信息

type BucketOptions

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

BucketOptions ...

type Channel

type Channel struct {
	Room *Room
	Next *Channel
	Prev *Channel
	// contains filtered or unexported fields
}

Channel in fact, Channel it's a user Connect session

func NewChannel

func NewChannel(size int) (c *Channel)

NewChannel ...

func (*Channel) Push

func (ch *Channel) Push(msg *proto.Msg) (err error)

Push ...

type Connect

type Connect struct {
}

Connect ...

func New

func New() *Connect

New ...

func (*Connect) InitConnectRPCServer

func (c *Connect) InitConnectRPCServer() (err error)

InitConnectRPCServer ...

func (*Connect) InitLogicRPCClient

func (c *Connect) InitLogicRPCClient() (err error)

InitLogicRPCClient ...

func (*Connect) InitWebsocket

func (c *Connect) InitWebsocket() error

InitWebsocket ...

func (*Connect) Run

func (c *Connect) Run()

Run ...

type DefaultOperator

type DefaultOperator struct {
}

DefaultOperator ...

func (*DefaultOperator) Connect

func (o *DefaultOperator) Connect(conn *proto.ConnectRequest) (uid int, err error)

Connect rpc call logic layer

func (*DefaultOperator) DisConnect

func (o *DefaultOperator) DisConnect(disConn *proto.DisConnectRequest) (err error)

DisConnect rpc call logic layer

type Operator

type Operator interface {
	Connect(conn *proto.ConnectRequest) (int, error)
	DisConnect(disConn *proto.DisConnectRequest) (err error)
}

Operator ...

type RPCConnect

type RPCConnect struct {
}

RPCConnect ...

func (*RPCConnect) Connect

func (rpc *RPCConnect) Connect(connReq *proto.ConnectRequest) (uid int, err error)

Connect ...

func (*RPCConnect) DisConnect

func (rpc *RPCConnect) DisConnect(disConnReq *proto.DisConnectRequest) (err error)

DisConnect ...

type RPCConnectPush

type RPCConnectPush struct {
}

RPCConnectPush ...

func (*RPCConnectPush) PushRoomCount

func (rpc *RPCConnectPush) PushRoomCount(ctx context.Context, pushRoomMsgReq *proto.PushRoomMsgRequest, successReply *proto.SuccessReply) (err error)

PushRoomCount ...

func (*RPCConnectPush) PushRoomInfo

func (rpc *RPCConnectPush) PushRoomInfo(ctx context.Context, pushRoomMsgReq *proto.PushRoomMsgRequest, successReply *proto.SuccessReply) (err error)

PushRoomInfo ...

func (*RPCConnectPush) PushRoomMsg

func (rpc *RPCConnectPush) PushRoomMsg(ctx context.Context, pushRoomMsgReq *proto.PushRoomMsgRequest, successReply *proto.SuccessReply) (err error)

PushRoomMsg ...

func (*RPCConnectPush) PushSingleMsg

func (rpc *RPCConnectPush) PushSingleMsg(ctx context.Context, pushMsgReq *proto.PushMsgRequest, successReply *proto.SuccessReply) (err error)

PushSingleMsg ...

type Room

type Room struct {
	ID          int
	OnlineCount int // room online user count
	// contains filtered or unexported fields
}

Room ...

func NewRoom

func NewRoom(roomID int) *Room

NewRoom ...

func (*Room) DeleteChannel

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

DeleteChannel 某个用户离开房间

func (*Room) Push

func (r *Room) Push(msg *proto.Msg)

Push 向一个房间中的所有用户推送消息

func (*Room) Put

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

Put 某个用户进入房间

type Server

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

Server ...

var DefaultServer *Server

DefaultServer ...

func NewServer

func NewServer(b []*Bucket, o Operator, options ServerOptions) *Server

NewServer ...

func (*Server) Bucket

func (s *Server) Bucket(userID int) *Bucket

Bucket reduce lock competition, use google city hash insert to different bucket

type ServerOptions

type ServerOptions struct {
	WriteWait       time.Duration
	PongWait        time.Duration
	PingPeriod      time.Duration
	MaxMessageSize  int64
	ReadBufferSize  int
	WriteBufferSize int
	BroadcastSize   int
}

ServerOptions ...

Jump to

Keyboard shortcuts

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