logic

package
v0.0.0-...-9fc3494 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoadBalancer

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

LoadBalancer load balancer.

func NewLoadBalancer

func NewLoadBalancer() *LoadBalancer

NewLoadBalancer new a load balancer.

func (*LoadBalancer) NodeAddrs

func (lb *LoadBalancer) NodeAddrs(region, domain string, regionWeight float64) (domains, addrs []string)

NodeAddrs return node addrs.

func (*LoadBalancer) Size

func (lb *LoadBalancer) Size() int

Size return node size.

func (*LoadBalancer) Update

func (lb *LoadBalancer) Update(ins []*naming.Instance)

Update update server nodes.

type Logic

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

Logic struct

func New

func New(c *conf.Config) (l *Logic)

New init

func (*Logic) Close

func (l *Logic) Close()

Close close resources.

func (*Logic) Connect

func (l *Logic) Connect(c context.Context, server, cookie string, token []byte) (mid int64, key, roomID string, accepts []int32, hb int64, err error)

Connect connected a conn. 把 user 的连接信息记录到 Redis 里。

func (*Logic) Disconnect

func (l *Logic) Disconnect(c context.Context, mid int64, key, server string) (has bool, err error)

Disconnect disconnect a conn. 从 Redis 中删除 user 的连接信息。

func (*Logic) Heartbeat

func (l *Logic) Heartbeat(c context.Context, mid int64, key, server string) (err error)

Heartbeat heartbeat a conn. 更新某个 user 的 redis 过期时间。

func (*Logic) NodesInstances

func (l *Logic) NodesInstances(c context.Context) (res []*naming.Instance)

NodesInstances get servers info.

func (*Logic) NodesWeighted

func (l *Logic) NodesWeighted(c context.Context, platform, clientIP string) *pb.NodesReply

NodesWeighted get node list.

func (*Logic) OnlineRoom

func (l *Logic) OnlineRoom(c context.Context, typ string, rooms []string) (res map[string]int32, err error)

根据房间 type 与 room id 取出房间在线人数。

func (*Logic) OnlineTop

func (l *Logic) OnlineTop(c context.Context, typ string, n int) (tops []*model.Top, err error)

OnlineTop get the top online. 取出在线人数最高的 n 个房间

func (*Logic) OnlineTotal

func (l *Logic) OnlineTotal(c context.Context) (int64, int64)

OnlineTotal get all online. 取出当前

func (*Logic) Ping

func (l *Logic) Ping(c context.Context) (err error)

Ping ping resources is ok.

func (*Logic) PushAll

func (l *Logic) PushAll(c context.Context, op, speed int32, msg []byte) (err error)

PushAll push a message to all. 全局房间广播推送,但有限制 operation 。

func (*Logic) PushKeys

func (l *Logic) PushKeys(c context.Context, op int32, keys []string, msg []byte) (err error)

根据 user key 推送消息

func (*Logic) PushMids

func (l *Logic) PushMids(c context.Context, op int32, mids []int64, msg []byte) (err error)

PushMids push a message by mid. 根据 user id 推送消息

func (*Logic) PushRoom

func (l *Logic) PushRoom(c context.Context, op int32, typ, room string, msg []byte) (err error)

PushRoom push a message by room. 单房间广播推送。

func (*Logic) Receive

func (l *Logic) Receive(c context.Context, mid int64, proto *grpc.Proto) (err error)

Receive receive a message.

func (*Logic) RenewOnline

func (l *Logic) RenewOnline(c context.Context, server string, roomCount map[string]int32) (map[string]int32, error)

RenewOnline renew a server online.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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