cmd

package
v0.0.54 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Status_name = map[int32]string{
		0: "Init",
		2: "Close",
		3: "Live",
	}
	Status_value = map[string]int32{
		"Init":  0,
		"Close": 2,
		"Live":  3,
	}
)

Enum value maps for Status.

View Source
var File_packmsg_proto protoreflect.FileDescriptor

Functions

func PackContentToPackage

func PackContentToPackage(bufContent []byte) []byte

func PackPackage

func PackPackage(id interface{}, data proto.Message) []byte

func PackProtoToPackage

func PackProtoToPackage(message proto.Message, cmd int32) []byte

func SendToClient

func SendToClient(conn net2.Conn, message *PackMsg, cmdForLog int32) bool

func SendToSingleServer

func SendToSingleServer(conn net2.Conn, message proto.Message) bool

func SendToSingleServerNoLen

func SendToSingleServerNoLen(conn net2.Conn, message *AgentData) bool

Types

type AgentData

type AgentData struct {
	Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` //服务ID
	// uint32 sid = 2;//连接的索引
	CliId  uint64 `protobuf:"varint,3,opt,name=cliId,proto3" json:"cliId,omitempty"` //客户端ID
	Status Status `protobuf:"varint,4,opt,name=status,proto3,enum=cmd.Status" json:"status,omitempty"`
	// string ip = 5;//仅连接的时候传值
	Data   []byte `protobuf:"bytes,6,opt,name=data,proto3" json:"data,omitempty"`
	Close  bool   `protobuf:"varint,7,opt,name=close,proto3" json:"close,omitempty"`   //是否关闭连接=>来自服务器
	Ws     string `protobuf:"bytes,8,opt,name=ws,proto3" json:"ws,omitempty"`          //接入地址
	Weight int32  `protobuf:"varint,9,opt,name=weight,proto3" json:"weight,omitempty"` //权重
	// contains filtered or unexported fields
}

func (*AgentData) Descriptor deprecated

func (*AgentData) Descriptor() ([]byte, []int)

Deprecated: Use AgentData.ProtoReflect.Descriptor instead.

func (*AgentData) GetCliId

func (x *AgentData) GetCliId() uint64

func (*AgentData) GetClose

func (x *AgentData) GetClose() bool

func (*AgentData) GetData

func (x *AgentData) GetData() []byte

func (*AgentData) GetId

func (x *AgentData) GetId() uint32

func (*AgentData) GetStatus

func (x *AgentData) GetStatus() Status

func (*AgentData) GetWeight

func (x *AgentData) GetWeight() int32

func (*AgentData) GetWs

func (x *AgentData) GetWs() string

func (*AgentData) ProtoMessage

func (*AgentData) ProtoMessage()

func (*AgentData) ProtoReflect

func (x *AgentData) ProtoReflect() protoreflect.Message

func (*AgentData) Reset

func (x *AgentData) Reset()

func (*AgentData) String

func (x *AgentData) String() string

type Context

type Context struct {
	net2.Conn
	Head *PackMsg
	// contains filtered or unexported fields
}

func (*Context) Abort

func (c *Context) Abort()

func (*Context) BackData

func (c *Context) BackData(data proto.Message) bool

func (*Context) BackDataBuf

func (c *Context) BackDataBuf(data []byte) bool

func (*Context) BackRet

func (c *Context) BackRet(ret int32) bool

func (*Context) BackRetTip

func (c *Context) BackRetTip(ret int32, tip string) bool

func (*Context) BackWait

func (c *Context) BackWait() bool

去掉客户端的seq倒计时,但是没有对应的CMD回调

func (*Context) BackWait0

func (c *Context) BackWait0() bool

当前不回应客户端,保持代码完整性

func (*Context) Next

func (c *Context) Next() bool

func (*Context) Reset

func (c *Context) Reset(msg *PackMsg, handlers HandlersChan) error

func (*Context) ResetNil

func (c *Context) ResetNil()

func (*Context) SendBuff

func (c *Context) SendBuff(bufPackage []byte) bool

线程安全版本

func (*Context) SendData

func (c *Context) SendData(cmd interface{}, data proto.Message) bool

func (*Context) SendPackMsg

func (c *Context) SendPackMsg(head *PackMsg) bool

func (*Context) SendRet

func (c *Context) SendRet(cmd interface{}, ret int32) bool

func (*Context) SendTip

func (c *Context) SendTip(cmd interface{}, ret int32, tip string) bool

type Handler

type Handler func() bool

type HandlersChan

type HandlersChan []Handler

type PackMsg

type PackMsg struct {
	Cmd    int32  `protobuf:"varint,1,opt,name=cmd,proto3" json:"cmd,omitempty"`      //Cmd
	Seq    int32  `protobuf:"varint,2,opt,name=seq,proto3" json:"seq,omitempty"`      //序列号
	Ret    int32  `protobuf:"varint,3,opt,name=ret,proto3" json:"ret,omitempty"`      //返回值
	Binary []byte `protobuf:"bytes,4,opt,name=binary,proto3" json:"binary,omitempty"` //包内容
	Tip    string `protobuf:"bytes,5,opt,name=tip,proto3" json:"tip,omitempty"`       //服务器传来的提示消息内容
	// contains filtered or unexported fields
}

func PackData

func PackData(cmd interface{}, data proto.Message) *PackMsg

func (*PackMsg) Descriptor deprecated

func (*PackMsg) Descriptor() ([]byte, []int)

Deprecated: Use PackMsg.ProtoReflect.Descriptor instead.

func (*PackMsg) GetBinary

func (x *PackMsg) GetBinary() []byte

func (*PackMsg) GetCmd

func (x *PackMsg) GetCmd() int32

func (*PackMsg) GetRet

func (x *PackMsg) GetRet() int32

func (*PackMsg) GetSeq

func (x *PackMsg) GetSeq() int32

func (*PackMsg) GetTip

func (x *PackMsg) GetTip() string

func (*PackMsg) ProtoMessage

func (*PackMsg) ProtoMessage()

func (*PackMsg) ProtoReflect

func (x *PackMsg) ProtoReflect() protoreflect.Message

func (*PackMsg) Reset

func (x *PackMsg) Reset()

func (*PackMsg) String

func (x *PackMsg) String() string

type Status

type Status int32

网关数据

const (
	Status_Init Status = 0
	// Connect = 1; 不再需要单独的Connect;在Live中自动判断
	Status_Close Status = 2
	Status_Live  Status = 3
)

func (Status) Descriptor

func (Status) Descriptor() protoreflect.EnumDescriptor

func (Status) Enum

func (x Status) Enum() *Status

func (Status) EnumDescriptor deprecated

func (Status) EnumDescriptor() ([]byte, []int)

Deprecated: Use Status.Descriptor instead.

func (Status) Number

func (x Status) Number() protoreflect.EnumNumber

func (Status) String

func (x Status) String() string

func (Status) Type

func (Status) Type() protoreflect.EnumType

Jump to

Keyboard shortcuts

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