router

package
v0.0.0-...-d436db8 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DisconnectAction = iota
)

Variables

View Source
var GorpcClient *gorpc.Client

Functions

func PrivateSendChatRoomNotify

func PrivateSendChatRoomNotify(message *logic.ChatRoomMessage, userGateways []*logic.UserGateway, traceId string) error

func SendChatRoomBroadcast

func SendChatRoomBroadcast(message *logic.ChatRoomMessage, gatewayAddrs map[string]int, traceId string) error

func SendChatRoomNotify

func SendChatRoomNotify(message *logic.ChatRoomMessage, gatewayAddrs map[string]int, traceId string) error

func SendChatRoomNotifyBatch

func SendChatRoomNotifyBatch(msgs []*logic.ChatRoomMessageNotify, gwys map[string]int, isWeb bool) error

func SendChatRoomNotifyWithDelay

func SendChatRoomNotifyWithDelay(message *logic.ChatRoomMessage, gatewayAddrs map[string]int, traceId string, delay, interval time.Duration) error

func SendMsgNotify

func SendMsgNotify(gatewayAddr string, tags []string, connIds []logic.ConnectionId, messageNotify *logic.MessageNotify) error

func SendOnlineBroadcast

func SendOnlineBroadcast(message *logic.ChatRoomMessage, gatewayAddrs map[string]int, traceId string) error

func SendPushNotifyBatch

func SendPushNotifyBatch(req []*ChatPushNotify) error

func SendPushTags

func SendPushTags(tags, gatewayAddrs []string, sender, channel, traceSn string, msgId uint64) error

func SendReConnectNotify

func SendReConnectNotify(ip string, port uint32, moreIps []string, gateways []string, tags []string, userGateways []*logic.UserGateway) error

发送reconnect请求

Types

type ChatPushNotify

type ChatPushNotify struct {
	Appid       int
	Receiver    string
	GatewayAddr string
	ConnId      logic.ConnectionId
	Sender      string
	Channel     string
	MsgId       uint64
	TraceSN     string
}

* Center uses this to send push request to router * * Appid: application, Huajiao is 2080 * Receiver: is push receiver * GateWays: is gateway information which receiver logged on, there might be more than one gateway * Sender: is who sends new message * Channel: indicates channel which new message is stored, so far only 'notify' * MsgId: new message id * TraceSN: trace sn

type ChatPushTags

type ChatPushTags struct {
	Tags         []string
	GatewayAddrs []string
	Sender       string
	Channel      string
	MsgId        uint64
	TraceSN      string
}

type ChatRoomNotifyBatchReq

type ChatRoomNotifyBatchReq struct {
	Msgs  []*logic.ChatRoomMessageNotify
	Gwys  map[string]int
	IsWeb bool
}

type GwPackage

type GwPackage struct {
	XimpBuff     *network.XimpBuffer // 前端传过来的包
	Property     map[string]string   // 前端保存的一些连接信息
	GatewayAddr  string              // gateway的gorpc ip和端口
	ConnectionId logic.ConnectionId  // 连接id
}

gateway往后路由需要发送的数据结构

type GwResp

type GwResp struct {
	XimpBuff         *network.XimpBuffer // 需要发往客户端的包
	Property         map[string]string   // 需要前端保存的一些连接信息
	Priority         bool                // 是否是优先下发内容
	Tags             map[string]bool     // 需要前端保存这个连接的tag信息,如果false表示删除
	Actions          []int               // 需要执行的动作
	Rkey             []byte              // 设置加密的key值
	HeartBeatTimeout time.Duration
	Err              string // 由于错误不能在gorpc里返回,所以只能在这里返回
}

发往gateway的数据结构

func Logout

func Logout(prop map[string]string, addr string, connectionId logic.ConnectionId) (*GwResp, error)

func RoutePackage

func RoutePackage(buf *network.XimpBuffer, prop map[string]string, addr string, connectionId logic.ConnectionId) (*GwResp, error)

给gateway调用,将包路由到router

func (*GwResp) String

func (gwr *GwResp) String() string

type MsgNotify

type MsgNotify struct {
	GatewayAddr   string
	Tags          []string
	ConnIds       []logic.ConnectionId
	MessageNotify *logic.MessageNotify
}

发送消息到router 需要带的消息

type ReConnectNotify

type ReConnectNotify struct {
	Ip           string
	Port         uint32
	MoreIps      []string
	Gateways     []string
	Tags         []string
	UserGateways []*logic.UserGateway
}

type RouterStat

type RouterStat struct {
	MltiInfos    uint64
	StatResponse int32
}

func GetRouterQps

func GetRouterQps(gorpcAddr string) (*RouterStat, error)

* get router qps from specified saver * @param gorpcAddr is specified saver go rpc address * @return (*RouterStat, nil) if successful, otherwise (*RouterStat{}, error) will be return

func GetRouterTotalOps

func GetRouterTotalOps(gorpcAddr string) (*RouterStat, error)

* get router total operations count after start from specified saver * @param gorpcAddr is specified saver go rpc address * @return (*RouterStat, nil) if successful, otherwise (*RouterStat{}, error) will be return

func (*RouterStat) Add

func (stat *RouterStat) Add(add *RouterStat) *RouterStat

* stat add add and then store result in stat * @param add is value will be added * @return stat with new value

func (*RouterStat) AtomicAddMltiInfos

func (stat *RouterStat) AtomicAddMltiInfos() uint64

atomic add functions

func (*RouterStat) AtomicCopyTo

func (stat *RouterStat) AtomicCopyTo(copy *RouterStat) *RouterStat

operations

  • this copy content of stat to 'copy' atomicly
  • @param copy is target the content copy to
  • @return copy if it is not nil, otherwise will return a new RouterStat point

func (*RouterStat) AtomicGetMltiInfos

func (stat *RouterStat) AtomicGetMltiInfos() uint64

func (*RouterStat) AtomicGetStatResponse

func (stat *RouterStat) AtomicGetStatResponse() bool

func (*RouterStat) AtomicMakeQps

func (stat *RouterStat) AtomicMakeQps(i uint64) string

* this computes qps with stat according to interval * @param i is interval which unit is second * @return a json string that include saver QPS information

func (*RouterStat) AtomicSetStatResponse

func (stat *RouterStat) AtomicSetStatResponse(value bool)

func (*RouterStat) QpsString

func (stat *RouterStat) QpsString() string

func (*RouterStat) String

func (stat *RouterStat) String() string

func (*RouterStat) Sub

func (stat *RouterStat) Sub(sub *RouterStat) *RouterStat

* stat subtract sub and then store result in stat * @param sub is value will be subtracted * @return stat with new value

Jump to

Keyboard shortcuts

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