logic

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: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VERF_CODE_SALT = "360tantan@1408$"

	DEFAULT_APPID     = 2080
	APPID_HUAJIAO     = 2080
	APPID_OVERSEA     = 2081
	APPID_HUAJIAO_STR = "2080"
)

Variables

View Source
var (
	ComponentTags map[string]string = map[string]string{
		"svn":          _SVN_,
		"version":      _VERSION_,
		"author":       _AUTHOR_,
		"compile_time": _COMPILETIME_,
	}
)
View Source
var RootDir = func() string {
	binDir, err := process.GetProcessBinaryDir()
	if err != nil {
		panic(err.Error())
	}
	return binDir + "/.."
}()

初始化项目根目录

View Source
var StaticConf = newStaticConfType()

Functions

func CheckIp

func CheckIp(ip string) bool

判断这个ip是否在我们的白名单中

func CheckRequestIp

func CheckRequestIp(r *http.Request) bool

func ClientIp

func ClientIp(r *http.Request) string

func FilterGatewayAddrs

func FilterGatewayAddrs(config map[int]int, members int, addrs map[string]int, priority bool) map[string]int

func GenerateChatRoomBroadcastTag

func GenerateChatRoomBroadcastTag(appid interface{}) string

func GenerateChatRoomTag

func GenerateChatRoomTag(appid interface{}, room string) string

func GenerateWebChatRoomTag

func GenerateWebChatRoomTag(appid interface{}, room string) string

func GetAllSubscribeSection

func GetAllSubscribeSection(component, nodeId string) []string

func GetAppids

func GetAppids() map[string]bool

func GetDefaultKey

func GetDefaultKey(appid, cversion uint16) []byte

func GetGatewayGorpcMap

func GetGatewayGorpcMap() map[string]int

func GetInnerIp

func GetInnerIp() string

func GetIp

func GetIp() string

如果无外网ip。那么返回内网ip

func GetRandApnsGorpc

func GetRandApnsGorpc() string

func GetRouterGorpc

func GetRouterGorpc() string

func GetRpcIndex

func GetRpcIndex(rpc string, rpcs []string) (index int)

func GetSaverGorpc

func GetSaverGorpc() string

func GetServerRoomName

func GetServerRoomName() string

获取当前组件所在的机房

func GetServerRoomNameSection

func GetServerRoomNameSection() string

func GetSessionGorpc

func GetSessionGorpc() string

func GetSn

func GetSn() uint64

func GetStatedCenterGorpc

func GetStatedCenterGorpc(key string) string

func GetStatedCoordinatorGorpc

func GetStatedCoordinatorGorpc(key string) string

func GetStatedCoordinatorGorpcs

func GetStatedCoordinatorGorpcs(key string) []string

coordinator可能是多发,所以获取到的是一个[]string

func GetStatedSessionGorpc

func GetStatedSessionGorpc(key string) string

func GetTraceId

func GetTraceId(gwaddr string, connectionId ConnectionId) string

func HumSize

func HumSize(bit uint64) string

func LogicSubscribe

func LogicSubscribe(nodeId string) []string

func MakeSecretRan

func MakeSecretRan(pwd, serverRan string) []byte

func MakeVerfCode

func MakeVerfCode(user string) string

func NetGlobalConf

func NetGlobalConf() *data.Global

从keeper取回来的配置

func RandString

func RandString(length int) string

可以优化,目前只返回是数字的随机串,可以加上字符

func ShowJson

func ShowJson(j interface{})

func StringToUint16

func StringToUint16(s string) uint16

func Sum

func Sum(key string) int

func UpdateDynamicConfType

func UpdateDynamicConfType()

动态配置结构更新,由keeper/client触发调用

Types

type ChatRoomMessage

type ChatRoomMessage struct {
	RoomID      string
	Sender      string
	Appid       uint16
	MsgType     int
	MsgContent  []byte
	RegMemCount int
	MemCount    int
	MsgID       uint
	MaxID       uint
	TimeStamp   int64
	Priority    bool
}

type ChatRoomMessageNotify

type ChatRoomMessageNotify struct {
	*ChatRoomMessage
	GatewayAddrs map[string]int
	TraceId      string
	Delay        time.Duration // 消息延迟多久后发送,由调用方传入
	Interval     time.Duration // 每个 gateway 发送消息间隔
}

type ChatRoomMsgRaw

type ChatRoomMsgRaw struct {
	Appid      uint16
	RoomID     string
	Sender     string
	MsgContent string
	MsgType    int
	Priority   int
	MsgId      uint
	TraceId    string
	MaxId      uint
}

聊天室消息的原始请求

type ConnectionId

type ConnectionId uint64

func (ConnectionId) String

func (self ConnectionId) String() string

type ConnectionIdGenerator

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

func NewConnectionIdGenerator

func NewConnectionIdGenerator() *ConnectionIdGenerator

func (*ConnectionIdGenerator) NextConnectionId

func (this *ConnectionIdGenerator) NextConnectionId() ConnectionId

type DynamicConfType

type DynamicConfType struct {
	Appids              map[string]bool
	LocalSaverRpc       string
	LocalSessionRpc     string
	LocalRouterRpc      string
	LocalCoordinatorRpc string
	GatewaySrMap        map[string]string
}

需要再处理的动态配置,每次从keeper取回来的配置有更新的话,会同步更新该结构

func DynamicConf

func DynamicConf() *DynamicConfType

获取动态配置

type MessageNotify

type MessageNotify struct {
	InfoType          string
	InfoContent       []byte
	InfoId            int64
	QueryAfterSeconds uint32
	ExpireTime        uint64
	Sender            string
}

func NewMessageNotify

func NewMessageNotify(infoType string, infoContent []byte, queryAfterSeconds uint32, expireTime uint64, sender string) *MessageNotify

type PrivateChatRoomMessageNotify

type PrivateChatRoomMessageNotify struct {
	*ChatRoomMessage
	UserGateways []*UserGateway
	TraceId      string
}

type UserGateway

type UserGateway struct {
	GatewayAddr string
	ConnId      ConnectionId
}

* describes the gateway information which user logged on * * GatewayAddr: is gateway address * ConnId: is connection id on gateway

Directories

Path Synopsis
Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT!
Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT! Code generated by tool/convert DO NOT EDIT!
Package pb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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