Documentation
¶
Overview ¶
Package grpool implements a goroutine reusable pool.
Index ¶
- Variables
- func Broadcast(msg *SendMsg) error
- func BroadcastAll(msg *SendMsg) error
- func InitWsPool(errfun func(err interface{}))
- func Send(msg *SendMsg) error
- type Client
- func (c *Client) Close()
- func (c *Client) GetRuntimeInfo() *RuntimeInfo
- func (c *Client) OnClose(h func())
- func (c *Client) OnError(h func(err error))
- func (c *Client) OnMessage(h func(msg *SendMsg))
- func (c *Client) OnOpen(h func())
- func (c *Client) OnPing(h func())
- func (c *Client) OnPong(h func())
- func (c *Client) OpenClient(w http.ResponseWriter, r *http.Request, head http.Header)
- func (c *Client) Send(msg *SendMsg) error
- type Config
- type Pool
- type RuntimeInfo
- type SendMsg
- func (*SendMsg) Descriptor() ([]byte, []int)deprecated
- func (x *SendMsg) GetChannel() []string
- func (x *SendMsg) GetCmd() int32
- func (x *SendMsg) GetCmdData() []byte
- func (x *SendMsg) GetDesc() string
- func (x *SendMsg) GetFromClientId() string
- func (x *SendMsg) GetLocalId() string
- func (x *SendMsg) GetMsg() string
- func (x *SendMsg) GetPriority() int32
- func (x *SendMsg) GetServerId() string
- func (x *SendMsg) GetStatus() int32
- func (x *SendMsg) GetTimestamp() int64
- func (x *SendMsg) GetToClientId() string
- func (*SendMsg) ProtoMessage()
- func (x *SendMsg) ProtoReflect() protoreflect.Message
- func (x *SendMsg) Reset()
- func (x *SendMsg) String() string
- type Server
Constants ¶
This section is empty.
Variables ¶
View Source
var File_sendMsg_proto protoreflect.FileDescriptor
Functions ¶
func BroadcastAll ¶
全局广播 广播一定要设置toClientId,这个对象可以确定广播超时消息回复对像 通过此方法进行广播的消息体,会对所有的类型和频道都进行广播
Types ¶
type Client ¶
type Client struct { Id string //标识连接的名称 IsClose bool //连接的状态。true为关闭 CloseTime int64 //连接断开的时间 // contains filtered or unexported fields }
Client is a middleman between the websocket connection and the hub.
func (*Client) OpenClient ¶
开启连接 serveWs handles websocket requests from the peer.
type Config ¶
type Config struct { Id string //标识连接的名称 Type string //连接类型或path Channel []string //连接注册频道类型方便广播等操作。做为一个数组存储。因为一个连接可以属多个频道 Goroutine int //每个连接开启的go程数里 默认为10 }
连接参数结构体
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Goroutine Pool
func New ¶
New creates and returns a new goroutine pool object. The parameter <limit> is used to limit the max goroutine count, which is not limited in default.
func (*Pool) Cap ¶
Cap returns the capacity of the pool. This capacity is defined when pool is created. If it returns -1 means no limit.
type RuntimeInfo ¶
type SendMsg ¶
type SendMsg struct { Cmd int32 `protobuf:"varint,1,opt,name=cmd,proto3" json:"cmd,omitempty"` Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` //消息发送时间 FromClientId string `protobuf:"bytes,3,opt,name=fromClientId,proto3" json:"fromClientId,omitempty"` //指令消息的来源。发送者的连接ID ToClientId string `protobuf:"bytes,4,opt,name=toClientId,proto3" json:"toClientId,omitempty"` //指令消息的接收者。发送给对应的客户端连接ID CmdData []byte `protobuf:"bytes,5,opt,name=cmdData,proto3" json:"cmdData,omitempty"` //对应指令的CmdData1的protobuf的message Status int32 `protobuf:"varint,6,opt,name=status,proto3" json:"status,omitempty"` //消息发送响应状态 Priority int32 `protobuf:"varint,7,opt,name=priority,proto3" json:"priority,omitempty"` //用于处理指令队列的优先级的权重值 LocalId string `protobuf:"bytes,8,opt,name=localId,proto3" json:"localId,omitempty"` //客户端标识消息的id,主要区分相同cmd的不同消息,方便收到回复分发处理等效果,考虑长度问题定义成string ServerId string `protobuf:"bytes,9,opt,name=serverId,proto3" json:"serverId,omitempty"` //服务端发送消息的ID,主要区分相同cmd的不同消息,方便服务端收到回复分发处理等效果,考虑长度问题定义成string Channel []string `protobuf:"bytes,10,rep,name=channel,proto3" json:"channel,omitempty"` //指定需要广播的频道,可以指定一个或多个频道 Msg string `protobuf:"bytes,11,opt,name=msg,proto3" json:"msg,omitempty"` //一般用于json数据传递,或消息发送响应内容 Desc string `protobuf:"bytes,12,opt,name=Desc,proto3" json:"Desc,omitempty"` //消息介绍内容,或其它数据 // contains filtered or unexported fields }
func (*SendMsg) Descriptor
deprecated
func (*SendMsg) GetChannel ¶
func (*SendMsg) GetCmdData ¶
func (*SendMsg) GetFromClientId ¶
func (*SendMsg) GetLocalId ¶
func (*SendMsg) GetPriority ¶
func (*SendMsg) GetServerId ¶
func (*SendMsg) GetTimestamp ¶
func (*SendMsg) GetToClientId ¶
func (*SendMsg) ProtoMessage ¶
func (*SendMsg) ProtoMessage()
func (*SendMsg) ProtoReflect ¶ added in v1.1.4
func (x *SendMsg) ProtoReflect() protoreflect.Message
Source Files
¶
Click to show internal directories.
Click to hide internal directories.