Documentation ¶
Overview ¶
Package log provides 全局日志记录,内部使用beego/log
Index ¶
- Constants
- Variables
- func AddRuntime(file string, line int, goroutineId string)
- func CatchPanic()
- func DelRuntime(file string, line int, goroutineId string)
- func GetRandNum(n int64) int64
- func GetRandomDomain() string
- func GlobalInit(kind, path, level string, length int) error
- func InitRuntimeMap()
- func MarshalPacket(msgID uint64, data, dataplus *[]byte) (*[]byte, error)
- func NewSessionStore() *sessionStore
- func PrintPanicStack()
- func ReadFull(length int, conn net.Conn) ([]byte, error)
- func ReadQuicFull(length int, conn quic.Stream) ([]byte, error)
- func SetLogPath(logPath string)
- func TimeFormatToNanosecondStr() string
- type AddressNet
- type Auth
- type Client
- func (this *Client) Close()
- func (this *Client) Connect(ip string, port uint32) (remoteName string, params interface{}, connectKey string, err error)
- func (this *Client) Get(name string) interface{}
- func (this *Client) GetAreaName() string
- func (this Client) GetConnType() string
- func (this *Client) GetIndex() uint64
- func (this *Client) GetMachineID() string
- func (this *Client) GetName() string
- func (this *Client) GetRemoteHost() string
- func (this *Client) GetSetGodTime() int64
- func (this *Client) Send(msgID uint64, data, dataplus *[]byte, timeout time.Duration) error
- func (this *Client) Set(name string, value interface{})
- func (this *Client) SetName(name string)
- func (this *Client) SetTryIsClose(isClose bool) bool
- type ClientNewConnCallback
- type ClientQuic
- func (this *ClientQuic) Close()
- func (this *ClientQuic) Connect(ip string, port uint32) (remoteName string, params interface{}, connectKey string, err error)
- func (this *ClientQuic) Get(name string) interface{}
- func (this *ClientQuic) GetAreaName() string
- func (this ClientQuic) GetConnType() string
- func (this *ClientQuic) GetIndex() uint64
- func (this *ClientQuic) GetMachineID() string
- func (this *ClientQuic) GetName() string
- func (this *ClientQuic) GetRemoteHost() string
- func (this *ClientQuic) GetSetGodTime() int64
- func (this *ClientQuic) Send(msgID uint64, data, dataplus *[]byte, timeout time.Duration) error
- func (this *ClientQuic) Set(name string, value interface{})
- func (this *ClientQuic) SetName(name string)
- func (this *ClientQuic) SetTryIsClose(isClose bool) bool
- type CloseCallback
- type Controller
- type ControllerImpl
- type Engine
- func (this *Engine) AddAuth(auth Auth)
- func (this *Engine) AddClientConn(areaName []byte, ip string, port uint32, powerful bool, onlyAddOneSess string) (ss Session, err error)
- func (this *Engine) AddClientQuicConn(areaName []byte, ip string, port uint32, powerful bool, onlyAddOneSess string) (ss Session, err error)
- func (this *Engine) AddConnectBySessionAndNode(areaName []byte, clientConn *Client, params interface{})
- func (this *Engine) AddDownSession(areaName []byte, ss Session)
- func (this *Engine) AddInterceptor(itpr Interceptor)
- func (this *Engine) AddOnlyConnect(ss []string)
- func (this *Engine) AddQuicConnectBySessionAndNode(areaName []byte, clientConn *ClientQuic, params interface{})
- func (this *Engine) AddUpSession(areaName []byte, ss Session)
- func (this *Engine) CheckInSessionByIndex(ss Session) bool
- func (this *Engine) CompareAddressNet(node AddressNet) bool
- func (this *Engine) DelNodeDownSession(areaName []byte, ss Session)
- func (this *Engine) DelNodeUpSession(areaName []byte, ss Session)
- func (this *Engine) DeleteConnecting(name string)
- func (this *Engine) DelyDeleteConnecting(name string)
- func (this *Engine) Destroy(areaName []byte)
- func (this *Engine) GetAllDownSession(areaName []byte) []Session
- func (this *Engine) GetAllDownUp(areaName []byte) []string
- func (this *Engine) GetAllSession(areaName []byte) []Session
- func (this *Engine) GetAllUpSession(areaName []byte) []Session
- func (this *Engine) GetAuth(areaName string) (auth Auth, exist bool)
- func (this *Engine) GetClientConnCallback(areaName string) (callback ClientNewConnCallback, exist bool)
- func (this *Engine) GetCloseCallback(areaName string) (callback CloseCallback, exist bool)
- func (this *Engine) GetConnectInfoByIpAddr(areaName []byte, ip string, port uint32) (ss *Client, node interface{}, err error)
- func (this *Engine) GetGodAddr(areaName []byte) (ip string, port uint16)
- func (this *Engine) GetOnlyConnectNum() int
- func (this *Engine) GetQuicConnectInfoByIpAddr(areaName []byte, ip string, port uint32) (ss *ClientQuic, node interface{}, err error)
- func (this *Engine) GetServerConnCallback(areaName string) (callback ServerNewConnCallback, exist bool)
- func (this *Engine) GetSession(areaName []byte, name string) (Session, bool)
- func (this *Engine) GetSessionAll(areaName []byte, name string) ([]Session, bool)
- func (this *Engine) GetSessionCnt(areaName []byte) int64
- func (this *Engine) GetSortSessionByKey(key string) ([]AddressNet, bool)
- func (this *Engine) GetTcpHost() (string, uint16)
- func (this *Engine) IsNodeUpdownSess(areaName []byte, addr AddressNet) bool
- func (this *Engine) Listen(ip string, port uint32, async bool) error
- func (this *Engine) ListenByListener(listener *net.TCPListener, async bool) error
- func (this *Engine) ListenQuic(ip string, port uint32, async bool) error
- func (this *Engine) LoadOrStoreConnecting(name string) bool
- func (this *Engine) Recovery()
- func (this *Engine) RecvKey(conn net.Conn, name string) (remoteName, machineID, remoteAreaName string, setGodTime int64, ...)
- func (this *Engine) RecvQuicKey(conn quic.Connection, stream quic.Stream, name string) (remoteName, machineID, remoteAreaName string, setGodTime int64, ...)
- func (this *Engine) RegisterMsg(areaName []byte, msgId uint64, handler MsgHandler)
- func (this *Engine) RemoveCustomSession(ss Session)
- func (this *Engine) RemoveSession(areaName []byte, ss Session)
- func (this *Engine) SetClientConnCallback(areaName []byte, call ClientNewConnCallback)
- func (this *Engine) SetCloseCallback(areaName []byte, call CloseCallback)
- func (this *Engine) SetGodAddr(areaName []byte, ip string, port uint16)
- func (this *Engine) SetServerConnCallback(areaName []byte, call ServerNewConnCallback)
- func (this *Engine) SetSortSessionByKey(key string, addrs []AddressNet)
- func (this *Engine) StoreConnecting(name string)
- func (this *Engine) Suspend()
- type GetPacket
- type GetPacketBytes
- type GodAddrInfo
- type Interceptor
- type InterceptorProvider
- type LogOne
- type LogQueue
- type MsgHandler
- type NoneAuth
- func (this *NoneAuth) RecvKey(conn net.Conn, name string) (remoteName, machineID string, setGodTime int64, params interface{}, err error)
- func (this *NoneAuth) SendKey(conn net.Conn, session Session, name string, setGodAddr bool) (remoteName, machineID string, setGodTime int64, params interface{}, err error)
- type Packet
- type Router
- type SendPacket
- type SendQueue
- type ServerConn
- func (this *ServerConn) Close()
- func (this *ServerConn) Get(name string) interface{}
- func (this *ServerConn) GetAreaName() string
- func (this ServerConn) GetConnType() string
- func (this *ServerConn) GetIndex() uint64
- func (this *ServerConn) GetMachineID() string
- func (this *ServerConn) GetName() string
- func (this *ServerConn) GetRemoteHost() string
- func (this *ServerConn) GetSetGodTime() int64
- func (this *ServerConn) Send(msgID uint64, data, dataplus *[]byte, timeout time.Duration) error
- func (this *ServerConn) SendJSON(msgID uint64, data interface{}, waite bool) error
- func (this *ServerConn) SendOld(msgID uint64, data, dataplus *[]byte, waite bool) error
- func (this *ServerConn) Set(name string, value interface{})
- func (this *ServerConn) SetName(name string)
- func (this *ServerConn) SetTryIsClose(isClose bool) bool
- type ServerNewConnCallback
- type ServerQuicConn
- func (this *ServerQuicConn) Close()
- func (this *ServerQuicConn) Get(name string) interface{}
- func (this *ServerQuicConn) GetAreaName() string
- func (this ServerQuicConn) GetConnType() string
- func (this *ServerQuicConn) GetIndex() uint64
- func (this *ServerQuicConn) GetMachineID() string
- func (this *ServerQuicConn) GetName() string
- func (this *ServerQuicConn) GetRemoteHost() string
- func (this *ServerQuicConn) GetSetGodTime() int64
- func (this *ServerQuicConn) Send(msgID uint64, data, dataplus *[]byte, timeout time.Duration) error
- func (this *ServerQuicConn) SendJSON(msgID uint64, data interface{}, waite bool) error
- func (this *ServerQuicConn) Set(name string, value interface{})
- func (this *ServerQuicConn) SetName(name string)
- func (this *ServerQuicConn) SetTryIsClose(isClose bool) bool
- type Session
- type TimeOut
Constants ¶
const ( SendQueueCacheNum = 100000 MSGID_heartbeat = 0 //心跳连接 MaxSendQueueDealCnt = 20 // 同时处理协程数量 MaxQueue = 100000 //伸缩发送队列最大长度 AreaNameResult_same = 1 //相同 AreaNameResult_different = 2 //不同 MaxRetryCnt = 2 //发送最大重试次数 )
const ( AddressUp = "up" //addSession方法添加upSession标识 AddressDown = "down" //addSession方法添加downSession标识 BothMod = "both" //AddClientConn方法全规则添加模式 OnebyoneMod = "onebyone" //AddClientConn方法onebyone规则添加模式 KadMod = "kad" //AddClientConn方法kad规则添加模式 VnodeMod = "vnode" //AddClientConn方法vnode规则添加模式 )
const ( CONN_TYPE_TCP = 0 // tcp连接 CONN_TYPE_QUIC = 1 // quic连接 )
const ( LOG_default = 0 // LOG_console = 1 //打印到控制台 LOG_file = 2 //打印到文件 LOG_console_and_file = 3 //同时打印到控制台和文件 )
Variables ¶
var ( ERROR_send_cache_full = errors.New("send cache full error") //发送队列满了 ERROR_send_cache_close = errors.New("send cache close") //发送队列关闭 ERROR_send_timeout = errors.New("send timeout error") //发送超时 Error_different_netid = errors.New("netid different") // Error_node_unwanted = errors.New("node unwante") //不需要的节点 SendTimeOut = time.Second * 10 //默认超时时间 )
var Log *logs.BeeLogger
"github.com/astaxie/beego/logs"
) beego Log
Functions ¶
func AddRuntime ¶
func DelRuntime ¶
func GlobalInit ¶
func InitRuntimeMap ¶
func InitRuntimeMap()
func NewSessionStore ¶
func NewSessionStore() *sessionStore
func ReadQuicFull ¶
func SetLogPath ¶
func SetLogPath(logPath string)
func TimeFormatToNanosecondStr ¶
func TimeFormatToNanosecondStr() string
Types ¶
type AddressNet ¶
type AddressNet []byte
节点地址
func AddressFromB58String ¶
func AddressFromB58String(str string) AddressNet
func BuildAddr ¶
func BuildAddr(pubKey []byte) AddressNet
通过公钥生成网络节点地址,将公钥两次hash得到网络节点地址 @version []byte 版本号(如比特币主网版本号“0x00")
func (*AddressNet) B58String ¶
func (this *AddressNet) B58String() string
type Auth ¶
type Auth interface { SendKey(conn net.Conn, session Session, name string, setGodAddr bool) (remoteName, machineID string, setGodTime int64, params interface{}, connectKey string, err error) RecvKey(conn net.Conn, name string) (remoteName, machineID string, setGodTime int64, params interface{}, connectKey string, err error) GetAreaName() (areaName string) SendQuicKey(conn quic.Connection, stream quic.Stream, session Session, name string, setGodAddr bool) (remoteName, machineID string, setGodTime int64, params interface{}, connectKey string, err error) RecvQuicKey(conn quic.Connection, stream quic.Stream, name string) (remoteName, machineID string, setGodTime int64, params interface{}, connectKey string, err error) }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
本机向其他服务器的连接
func (*Client) GetAreaName ¶
* GetAreaName 获取区域名称 * * @return areaName string 区域名称
func (Client) GetConnType ¶
func (this Client) GetConnType() string
func (*Client) GetSetGodTime ¶
* GetSetGodTime 获取设置超级代理的时间 * * @return setGodTime int64 设置超级代理的时间
func (*Client) SetTryIsClose ¶
尝试设置为是否关闭 @return bool 是否设置成功
type ClientNewConnCallback ¶
客户端有新连接,触发的回调方法
type ClientQuic ¶
type ClientQuic struct {
// contains filtered or unexported fields
}
本机向其他服务器的连接
func NewClientQuic ¶
func NewClientQuic(areaName []byte, name, ip string, port uint32) *ClientQuic
func (*ClientQuic) GetAreaName ¶
func (this *ClientQuic) GetAreaName() string
* GetAreaName 获取区域名称 * * @return areaName string 区域名称
func (ClientQuic) GetConnType ¶
func (this ClientQuic) GetConnType() string
func (*ClientQuic) GetIndex ¶
func (this *ClientQuic) GetIndex() uint64
func (*ClientQuic) GetSetGodTime ¶
func (this *ClientQuic) GetSetGodTime() int64
* GetSetGodTime 获取设置超级代理的时间 * * @return setGodTime int64 设置超级代理的时间
func (*ClientQuic) SetName ¶
func (this *ClientQuic) SetName(name string)
func (*ClientQuic) SetTryIsClose ¶
func (this *ClientQuic) SetTryIsClose(isClose bool) bool
尝试设置为是否关闭 @return bool 是否设置成功
type Controller ¶
type ControllerImpl ¶
type ControllerImpl struct {
// contains filtered or unexported fields
}
func (*ControllerImpl) GetAttribute ¶
func (this *ControllerImpl) GetAttribute(name string) interface{}
func (*ControllerImpl) GetSession ¶
func (this *ControllerImpl) GetSession(areaName []byte, name string) (Session, bool)
func (*ControllerImpl) SetAttribute ¶
func (this *ControllerImpl) SetAttribute(name string, value interface{})
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
不能设置handler运行总量,不能容忍业务阻塞,所以用户自己去处理
func (*Engine) AddClientConn ¶
func (this *Engine) AddClientConn(areaName []byte, ip string, port uint32, powerful bool, onlyAddOneSess string) (ss Session, err error)
添加一个连接,给这个连接取一个名字,连接名字可以在自定义权限验证方法里面修改 @powerful 是否是强连接 @return name 对方的名称
func (*Engine) AddClientQuicConn ¶
func (this *Engine) AddClientQuicConn(areaName []byte, ip string, port uint32, powerful bool, onlyAddOneSess string) (ss Session, err error)
添加一个Quic连接,给这个连接取一个名字,连接名字可以在自定义权限验证方法里面修改 @powerful 是否是强连接 @return name 对方的名称
func (*Engine) AddConnectBySessionAndNode ¶
func (this *Engine) AddConnectBySessionAndNode(areaName []byte, clientConn *Client, params interface{})
* 根据客户端连接session,和节点信息,建立连接处理 * @param clientConn 客户端连接session * @param params 连接的节点信息
func (*Engine) AddDownSession ¶
* downSession中添加session
func (*Engine) AddInterceptor ¶
func (this *Engine) AddInterceptor(itpr Interceptor)
添加一个拦截器,所有消息到达业务方法之前都要经过拦截器处理
func (*Engine) AddQuicConnectBySessionAndNode ¶
func (this *Engine) AddQuicConnectBySessionAndNode(areaName []byte, clientConn *ClientQuic, params interface{})
* 根据客户端连接session,和节点信息,建立连接处理 * @param clientConn 客户端连接session * @param params 连接的节点信息
func (*Engine) AddUpSession ¶
* upSession中添加session
func (*Engine) CheckInSessionByIndex ¶
* 检查是否存在特定session
func (*Engine) CompareAddressNet ¶
func (this *Engine) CompareAddressNet(node AddressNet) bool
自己比传入地址大 true 传入地址比自己大 false
func (*Engine) DelNodeDownSession ¶
* 删除downSession中某个特定session
func (*Engine) DelNodeUpSession ¶
* 删除upSession中某个特定session
func (*Engine) DeleteConnecting ¶
* 直接删除正在处于连接状态中的地址
func (*Engine) DelyDeleteConnecting ¶
* 延迟一秒删除正在处于连接状态中的地址
func (*Engine) GetAllDownSession ¶
* 获取本节点所有downSession
func (*Engine) GetAllDownUp ¶
* 获取本节点所有downSession 和 upSession
func (*Engine) GetAllSession ¶
* 获取区域名的所有session
func (*Engine) GetAllUpSession ¶
* 获取本节点所有upSession
func (*Engine) GetAuth ¶
* GetAuth 获取区域对应的区域信息管理器 * * @param areaName string 区域名称 * @return auth Auth 区域信息管理器 * @return exist bool 是否存在回调标识
func (*Engine) GetClientConnCallback ¶
func (this *Engine) GetClientConnCallback(areaName string) (callback ClientNewConnCallback, exist bool)
* GetClientConnCallback 获取区域对应的客户端端连接回调方法 * * @param areaName string 区域名称 * @return closeCallback ClientNewConnCallback 回调方法 * @return exist bool 是否存在回调标识
func (*Engine) GetCloseCallback ¶
func (this *Engine) GetCloseCallback(areaName string) (callback CloseCallback, exist bool)
* GetCloseCallback 获取区域对应的关闭回调方法 * * @param areaName string 区域名称 * @return call CloseCallback 关闭回调方法 * @return exist bool 是否存在回调标识
func (*Engine) GetConnectInfoByIpAddr ¶
func (this *Engine) GetConnectInfoByIpAddr(areaName []byte, ip string, port uint32) (ss *Client, node interface{}, err error)
* 根据ip地址及端口,获取连接session及node信息 * @param ip ip地址 * @param port 端口 * @param setGodAddr 是否设置对方为自己的上帝节点 * @return ss 连接session * @return node 连接节点node * @return err 是否发生错误
func (*Engine) GetGodAddr ¶
* 获取当前上帝节点地址 * * @auth qlw * @param areaName []byte 区域名称 * @return ip string ip地址 * @return port uint16 端口
func (*Engine) GetQuicConnectInfoByIpAddr ¶
func (this *Engine) GetQuicConnectInfoByIpAddr(areaName []byte, ip string, port uint32) (ss *ClientQuic, node interface{}, err error)
* 根据ip地址及端口,获取Quic连接session及node信息 * @param ip ip地址 * @param port 端口 * @param setGodAddr 是否设置对方为自己的上帝节点 * @return ss 连接session * @return node 连接节点node * @return err 是否发生错误
func (*Engine) GetServerConnCallback ¶
func (this *Engine) GetServerConnCallback(areaName string) (callback ServerNewConnCallback, exist bool)
* GetServerConnCallback 获取区域对应的服务端连接回调方法 * * @param areaName string 区域名称 * @return closeCallback ServerNewConnCallback 回调方法 * @return exist bool 是否存在回调标识
func (*Engine) GetSession ¶
获得session
func (*Engine) GetSessionAll ¶
获得某个地址所有session
func (*Engine) GetSessionCnt ¶
* 获取本节点session总数
func (*Engine) GetSortSessionByKey ¶
func (this *Engine) GetSortSessionByKey(key string) ([]AddressNet, bool)
* 通过字符串获取排序好的网络地址数组
func (*Engine) GetTcpHost ¶
获取监听地址和端口 格式:0.0.0.0:8888
func (*Engine) IsNodeUpdownSess ¶
func (this *Engine) IsNodeUpdownSess(areaName []byte, addr AddressNet) bool
真实节点onebyone规则连接,up和down地址
func (*Engine) ListenByListener ¶
func (this *Engine) ListenByListener(listener *net.TCPListener, async bool) error
func (*Engine) ListenQuic ¶
* 监听quic信息
func (*Engine) LoadOrStoreConnecting ¶
* 加载并保存到正处于连接状态的地址 * 返回 true map中存在 * 返回 false map中不存在并保存
func (*Engine) RecvKey ¶
func (this *Engine) RecvKey(conn net.Conn, name string) (remoteName, machineID, remoteAreaName string, setGodTime int64, params interface{}, connectKey string, err error)
* RecvKey 接收信息 * * @param conn Conn tcp连接 * @param name string 自己节点id * @return remoteName string 对方节点id * @return params interface 对方节点信息 * @return err error 错误信息 * @return remoteAreaName string 对方的域名,主要用于当本地启动了多个area时,根据域名来查找对应的回调
func (*Engine) RecvQuicKey ¶
func (this *Engine) RecvQuicKey(conn quic.Connection, stream quic.Stream, name string) (remoteName, machineID, remoteAreaName string, setGodTime int64, params interface{}, connectKey string, err error)
* RecvQuicKey 接收信息 * * @param conn Conn tcp连接 * @param name string 自己节点id * @return remoteName string 对方节点id * @return params interface 对方节点信息 * @return err error 错误信息 * @return remoteAreaName string 对方的域名,主要用于当本地启动了多个area时,根据域名来查找对应的回调
func (*Engine) RegisterMsg ¶
func (this *Engine) RegisterMsg(areaName []byte, msgId uint64, handler MsgHandler)
注册一个普通消息
func (*Engine) RemoveCustomSession ¶
* 删除customNameStore中特定session
func (*Engine) RemoveSession ¶
* 删除sessionStore中特定session
func (*Engine) SetClientConnCallback ¶
func (this *Engine) SetClientConnCallback(areaName []byte, call ClientNewConnCallback)
设置客户端新连接的回调方法
func (*Engine) SetCloseCallback ¶
func (this *Engine) SetCloseCallback(areaName []byte, call CloseCallback)
设置关闭连接回调方法
func (*Engine) SetGodAddr ¶
* 设置上帝节点地址 * * @auth qlw * @param ip string ip地址 * @param port uint16 端口
func (*Engine) SetServerConnCallback ¶
func (this *Engine) SetServerConnCallback(areaName []byte, call ServerNewConnCallback)
* 设置服务器有新连接的回调方法
func (*Engine) SetSortSessionByKey ¶
func (this *Engine) SetSortSessionByKey(key string, addrs []AddressNet)
* 使用字符串作为key存储排序好的地址数组
type GetPacketBytes ¶
type GodAddrInfo ¶
type GodAddrInfo struct {
// contains filtered or unexported fields
}
* GodAddrInfo 上帝地址信息
type Interceptor ¶
type Interceptor interface { In(c Controller, msg Packet) bool Out(c Controller, msg Packet) }
type InterceptorProvider ¶
type InterceptorProvider struct {
// contains filtered or unexported fields
}
func NewInterceptor ¶
func NewInterceptor() *InterceptorProvider
type LogQueue ¶
type LogQueue struct {
// contains filtered or unexported fields
}
var NLog *LogQueue = NewLog(LOG_console, "log.txt")
type MsgHandler ¶
type MsgHandler func(c Controller, msg Packet)
type NoneAuth ¶
type NoneAuth struct {
// contains filtered or unexported fields
}
type Packet ¶
type Packet struct { MsgID uint64 // Size uint64 //数据包长度,包含头部4字节 Data []byte Dataplus []byte //未加密部分数据分开 Session Session }
func RecvPackage ¶
系统默认的消息接收并转化为Packet的方法 一个packet包括包头和包体,保证在接收到包头后两秒钟内接收到包体,否则线程会一直阻塞 因此,引入了超时机制
func RecvQuicPackage ¶
系统默认的消息接收并转化为Packet的方法 一个packet包括包头和包体,保证在接收到包头后两秒钟内接收到包体,否则线程会一直阻塞 因此,引入了超时机制
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) AddRouter ¶
func (this *Router) AddRouter(areaName []byte, msgId uint64, handler MsgHandler)
* AddRouter 添加引擎路由 * * @param areaName []byte 区域名称 * @param msgId uint64 消息id *
func (*Router) GetHandler ¶
func (this *Router) GetHandler(areaName string, msgId uint64) MsgHandler
* GetHandler 根据区域名和消息号获取回调方法 * * @param areaName string 区域名 * @param msgId uint64 消息号 * @return handler MsgHandler 回调方法
func (*Router) RemoveHandlers ¶
* RemoveHandlers 移除区域名对应的所有消息号回调方法 * * @param areaName string 区域名
type SendPacket ¶
type SendPacket struct { ID uint64 // // contains filtered or unexported fields }
type SendQueue ¶
type SendQueue struct {
// contains filtered or unexported fields
}
func NewSendQueue ¶
func (*SendQueue) AddAndWaitTimeout ¶
添加
func (*SendQueue) GetQueueChan ¶
func (this *SendQueue) GetQueueChan() <-chan *SendPacket
type ServerConn ¶
type ServerConn struct { Ip string // Connected_time string // CloseTime string // // contains filtered or unexported fields }
其他计算机对本机的连接
func (*ServerConn) GetAreaName ¶
func (this *ServerConn) GetAreaName() string
* GetAreaName 获取区域名称 * * @return areaName string 区域名称
func (ServerConn) GetConnType ¶
func (this ServerConn) GetConnType() string
func (*ServerConn) GetIndex ¶
func (this *ServerConn) GetIndex() uint64
func (*ServerConn) GetSetGodTime ¶
func (this *ServerConn) GetSetGodTime() int64
* GetSetGodTime 获取设置超级代理的时间 * * @return setGodTime int64 设置超级代理的时间
func (*ServerConn) SendJSON ¶
func (this *ServerConn) SendJSON(msgID uint64, data interface{}, waite bool) error
给客户端发送数据
func (*ServerConn) SendOld ¶
func (this *ServerConn) SendOld(msgID uint64, data, dataplus *[]byte, waite bool) error
给客户端发送数据
func (*ServerConn) SetName ¶
func (this *ServerConn) SetName(name string)
func (*ServerConn) SetTryIsClose ¶
func (this *ServerConn) SetTryIsClose(isClose bool) bool
尝试设置为是否关闭 @return bool 是否设置成功
type ServerNewConnCallback ¶
服务器有新连接,触发的回调方法
type ServerQuicConn ¶
type ServerQuicConn struct { Ip string // Connected_time string // CloseTime string // // contains filtered or unexported fields }
其他计算机对本机的连接
func (*ServerQuicConn) GetAreaName ¶
func (this *ServerQuicConn) GetAreaName() string
* GetAreaName 获取区域名称 * * @return areaName string 区域名称
func (ServerQuicConn) GetConnType ¶
func (this ServerQuicConn) GetConnType() string
func (*ServerQuicConn) GetIndex ¶
func (this *ServerQuicConn) GetIndex() uint64
func (*ServerQuicConn) GetRemoteHost ¶
func (this *ServerQuicConn) GetRemoteHost() string
获取远程ip地址和端口
func (*ServerQuicConn) GetSetGodTime ¶
func (this *ServerQuicConn) GetSetGodTime() int64
* GetSetGodTime 获取设置超级代理的时间 * * @return setGodTime int64 设置超级代理的时间
func (*ServerQuicConn) SendJSON ¶
func (this *ServerQuicConn) SendJSON(msgID uint64, data interface{}, waite bool) error
给客户端发送数据
func (*ServerQuicConn) SetName ¶
func (this *ServerQuicConn) SetName(name string)
func (*ServerQuicConn) SetTryIsClose ¶
func (this *ServerQuicConn) SetTryIsClose(isClose bool) bool
尝试设置为是否关闭 @return bool 是否设置成功
type Session ¶
type Session interface { GetIndex() uint64 Send(msgID uint64, data, datapuls *[]byte, timeout time.Duration) error Close() Set(name string, value interface{}) Get(name string) interface{} GetName() string SetName(name string) GetRemoteHost() string GetMachineID() string GetAreaName() string GetSetGodTime() int64 GetConnType() string }