imsvc

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

*

  • Created by yson
  • Date: 2022-06-01
  • Time: 15:18

*

  • Created by yson
  • Date: 2022-06-01
  • Time: 15:18

*

  • Created by yson
  • Date: 2022-06-01
  • Time: 18:18

*

  • Created by yson
  • Date: 2022-06-01
  • Time: 15:18

Index

Constants

View Source
const NoRoom = -1

Variables

This section is empty.

Functions

func GenChannelIdByFriend

func GenChannelIdByFriend(userId, friendId int64) string

func GenChannelIdByGroup

func GenChannelIdByGroup(groupName string) string

func JoinChannelIds

func JoinChannelIds(uid string, channelIds ...string)

func Run

func Run(svcCtx *svc.ServiceContext) error

func SendMessageToChannelIds

func SendMessageToChannelIds(uid string, msg string, tp uint8, channelIds ...string)

func SendMessageToUid

func SendMessageToUid(uid string, toUId uint64, msg string, tp uint8)

func SendMessageToUids

func SendMessageToUids(uid string, msg string, tp uint8, toUIds ...uint64)

Types

type Bucket

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

func NewBucket

func NewBucket(bucketOptions BucketOptions) (b *Bucket)

func (*Bucket) BroadcastRoom

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

func (*Bucket) Channel

func (b *Bucket) Channel(userId int64) (ch *Channel)

func (*Bucket) DeleteChannel

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

func (*Bucket) PushRoom

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

func (*Bucket) Put

func (b *Bucket) Put(userId int64, roomId int64, ch *Channel) (err error)

func (*Bucket) Room

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

type BucketOptions

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

type Channel

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

in fact, Channel it's a user Connect session

func NewChannel

func NewChannel(size int) (c *Channel)

func (*Channel) Push

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

type Connect

type Connect struct {
	ServerId string
}

func New

func New() *Connect

type Room

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

func NewRoom

func NewRoom(roomId int64) *Room

func (*Room) DeleteChannel

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

func (*Room) Push

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

func (*Room) Put

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

type Server

type Server struct {
	Buckets []*Bucket
	Options ServerOptions

	Ctx    context.Context
	SvcCtx *svc.ServiceContext
	// contains filtered or unexported fields
}
var DefaultServer *Server

func NewServer

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

func (*Server) Bucket

func (s *Server) Bucket(userId int64) *Bucket

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

func (Server) Start

func (s Server) Start()

func (Server) Stop

func (s Server) Stop()

type ServerOptions

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

Jump to

Keyboard shortcuts

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