Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToUint32(bytes []byte) uint32
- func Decrypt(ciphertext []byte, gcm cipher.AEAD) ([]byte, error)
- func Encrypt(plaintext []byte, gcm cipher.AEAD) []byte
- func FatalNotNil(err error)
- func LogMessage(msg ...any)
- func LogNotNil(err error)
- func Marshal(m proto.Message) (bytes []byte, err error)
- func MarshalPack(pack proto.Message) (bytes []byte, err error)
- func NewEncryptionKey() *[32]byte
- func NewGCM(key *[32]byte) (gcm cipher.AEAD, err error)
- func PrintErr(errRes *ErrRes)
- func PrintMessage(msg *Msg)
- func SplitFunc(data []byte, atEOF bool) (advance int, token []byte, err error)
- func Uint32ToBytes(n uint32) (bytes []byte)
- func Unmarshal(bytes []byte, m proto.Message) (err error)
- type Auth
- type ErrCode
- type ErrRes
- type Msg
- func (*Msg) Descriptor() ([]byte, []int)deprecated
- func (x *Msg) GetData() []byte
- func (x *Msg) GetFrom() string
- func (x *Msg) GetId() int64
- func (x *Msg) GetKind() MsgKind
- func (x *Msg) GetTo() string
- func (*Msg) ProtoMessage()
- func (x *Msg) ProtoReflect() protoreflect.Message
- func (x *Msg) Reset()
- func (x *Msg) String() string
- type MsgKind
- type Online
- type OnlineKind
- type PackKind
- type Packet
- type Ping
- type Pong
- type Post
- type Push
- type PushKind
- type Signin
- type Signout
- type SignoutRes
- type Signup
- type Token
- type TokenRes
- func (*TokenRes) Descriptor() ([]byte, []int)deprecated
- func (x *TokenRes) GetCode() int32
- func (x *TokenRes) GetId() uint64
- func (x *TokenRes) GetToken() []byte
- func (x *TokenRes) GetUsername() string
- func (*TokenRes) ProtoMessage()
- func (x *TokenRes) ProtoReflect() protoreflect.Message
- func (x *TokenRes) Reset()
- func (x *TokenRes) String() string
- type User
- type Users
- type UsersRes
Constants ¶
View Source
const PackLenField = 4
Variables ¶
View Source
var ( PackKind_name = map[int32]string{ 0: "PONG", 1: "ERR", 2: "RES", 3: "PUSH", 4: "MSG", 5: "PING", 6: "SIGNUP", 7: "SIGNIN", 8: "TOKEN", 9: "SIGNOUT", 10: "USERS", } PackKind_value = map[string]int32{ "PONG": 0, "ERR": 1, "RES": 2, "PUSH": 3, "MSG": 4, "PING": 5, "SIGNUP": 6, "SIGNIN": 7, "TOKEN": 8, "SIGNOUT": 9, "USERS": 10, } )
Enum value maps for PackKind.
View Source
var ( MsgKind_name = map[int32]string{ 0: "TEXT", } MsgKind_value = map[string]int32{ "TEXT": 0, } )
Enum value maps for MsgKind.
View Source
var ( PushKind_name = map[int32]string{ 0: "ONLINE", } PushKind_value = map[string]int32{ "ONLINE": 0, } )
Enum value maps for PushKind.
View Source
var ( OnlineKind_name = map[int32]string{ 0: "ON", 1: "OFF", } OnlineKind_value = map[string]int32{ "ON": 0, "OFF": 1, } )
Enum value maps for OnlineKind.
View Source
var File_packet_proto protoreflect.FileDescriptor
View Source
var HomeDir = getHomeDir()
View Source
var WorkDir = getWorkDir()
Functions ¶
func BytesToUint32 ¶
func NewEncryptionKey ¶
func NewEncryptionKey() *[32]byte
func Uint32ToBytes ¶
Types ¶
type Auth ¶
type Auth struct { Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` Passhash []byte `protobuf:"bytes,2,opt,name=passhash,proto3" json:"passhash,omitempty"` // contains filtered or unexported fields }
func (*Auth) Descriptor
deprecated
func (*Auth) GetPasshash ¶
func (*Auth) GetUsername ¶
func (*Auth) ProtoMessage ¶
func (*Auth) ProtoMessage()
func (*Auth) ProtoReflect ¶
func (x *Auth) ProtoReflect() protoreflect.Message
type ErrRes ¶
type ErrRes struct { Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` // contains filtered or unexported fields }
func (*ErrRes) Descriptor
deprecated
func (*ErrRes) ProtoMessage ¶
func (*ErrRes) ProtoMessage()
func (*ErrRes) ProtoReflect ¶
func (x *ErrRes) ProtoReflect() protoreflect.Message
type Msg ¶
type Msg struct { Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` Kind MsgKind `protobuf:"varint,2,opt,name=kind,proto3,enum=lib.MsgKind" json:"kind,omitempty"` From string `protobuf:"bytes,3,opt,name=from,proto3" json:"from,omitempty"` To string `protobuf:"bytes,4,opt,name=to,proto3" json:"to,omitempty"` Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` // contains filtered or unexported fields }
func (*Msg) Descriptor
deprecated
func (*Msg) ProtoMessage ¶
func (*Msg) ProtoMessage()
func (*Msg) ProtoReflect ¶
func (x *Msg) ProtoReflect() protoreflect.Message
type MsgKind ¶
type MsgKind int32
const (
MsgKind_TEXT MsgKind = 0
)
func (MsgKind) Descriptor ¶
func (MsgKind) Descriptor() protoreflect.EnumDescriptor
func (MsgKind) EnumDescriptor
deprecated
func (MsgKind) Number ¶
func (x MsgKind) Number() protoreflect.EnumNumber
func (MsgKind) Type ¶
func (MsgKind) Type() protoreflect.EnumType
type Online ¶
type Online struct { Kind OnlineKind `protobuf:"varint,1,opt,name=kind,proto3,enum=lib.OnlineKind" json:"kind,omitempty"` Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` // contains filtered or unexported fields }
func (*Online) Descriptor
deprecated
func (*Online) GetKind ¶
func (x *Online) GetKind() OnlineKind
func (*Online) GetUsername ¶
func (*Online) ProtoMessage ¶
func (*Online) ProtoMessage()
func (*Online) ProtoReflect ¶
func (x *Online) ProtoReflect() protoreflect.Message
type OnlineKind ¶
type OnlineKind int32
const ( OnlineKind_ON OnlineKind = 0 OnlineKind_OFF OnlineKind = 1 )
func (OnlineKind) Descriptor ¶
func (OnlineKind) Descriptor() protoreflect.EnumDescriptor
func (OnlineKind) Enum ¶
func (x OnlineKind) Enum() *OnlineKind
func (OnlineKind) EnumDescriptor
deprecated
func (OnlineKind) EnumDescriptor() ([]byte, []int)
Deprecated: Use OnlineKind.Descriptor instead.
func (OnlineKind) Number ¶
func (x OnlineKind) Number() protoreflect.EnumNumber
func (OnlineKind) String ¶
func (x OnlineKind) String() string
func (OnlineKind) Type ¶
func (OnlineKind) Type() protoreflect.EnumType
type PackKind ¶
type PackKind int32
const ( // Server PackKind_PONG PackKind = 0 PackKind_ERR PackKind = 1 PackKind_RES PackKind = 2 PackKind_PUSH PackKind = 3 // All PackKind_MSG PackKind = 4 // Client PackKind_PING PackKind = 5 PackKind_SIGNUP PackKind = 6 PackKind_SIGNIN PackKind = 7 PackKind_TOKEN PackKind = 8 PackKind_SIGNOUT PackKind = 9 PackKind_USERS PackKind = 10 )
func (PackKind) Descriptor ¶
func (PackKind) Descriptor() protoreflect.EnumDescriptor
func (PackKind) EnumDescriptor
deprecated
func (PackKind) Number ¶
func (x PackKind) Number() protoreflect.EnumNumber
func (PackKind) Type ¶
func (PackKind) Type() protoreflect.EnumType
type Packet ¶
type Packet struct { Kind PackKind `protobuf:"varint,1,opt,name=kind,proto3,enum=lib.PackKind" json:"kind,omitempty"` Id uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` // contains filtered or unexported fields }
func (*Packet) Descriptor
deprecated
func (*Packet) ProtoMessage ¶
func (*Packet) ProtoMessage()
func (*Packet) ProtoReflect ¶
func (x *Packet) ProtoReflect() protoreflect.Message
type Ping ¶
type Ping struct { Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` // contains filtered or unexported fields }
func (*Ping) Descriptor
deprecated
func (*Ping) GetPayload ¶
func (*Ping) ProtoMessage ¶
func (*Ping) ProtoMessage()
func (*Ping) ProtoReflect ¶
func (x *Ping) ProtoReflect() protoreflect.Message
type Pong ¶
type Pong struct { Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` // contains filtered or unexported fields }
func (*Pong) Descriptor
deprecated
func (*Pong) GetPayload ¶
func (*Pong) ProtoMessage ¶
func (*Pong) ProtoMessage()
func (*Pong) ProtoReflect ¶
func (x *Pong) ProtoReflect() protoreflect.Message
type Post ¶
type Post interface { // 处理同步请求 Handle(req, res proto.Message) error // 发送非同步请求 Send(req proto.Message) error // 关闭并清理资源 Close() }
定义处理 packet 接口
type Push ¶
type Push struct { Kind PushKind `protobuf:"varint,1,opt,name=kind,proto3,enum=lib.PushKind" json:"kind,omitempty"` Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` // contains filtered or unexported fields }
func (*Push) Descriptor
deprecated
func (*Push) ProtoMessage ¶
func (*Push) ProtoMessage()
func (*Push) ProtoReflect ¶
func (x *Push) ProtoReflect() protoreflect.Message
type PushKind ¶
type PushKind int32
const (
PushKind_ONLINE PushKind = 0
)
func (PushKind) Descriptor ¶
func (PushKind) Descriptor() protoreflect.EnumDescriptor
func (PushKind) EnumDescriptor
deprecated
func (PushKind) Number ¶
func (x PushKind) Number() protoreflect.EnumNumber
func (PushKind) Type ¶
func (PushKind) Type() protoreflect.EnumType
type Signin ¶
type Signin struct { Auth *Auth `protobuf:"bytes,1,opt,name=auth,proto3" json:"auth,omitempty"` // contains filtered or unexported fields }
func (*Signin) Descriptor
deprecated
func (*Signin) ProtoMessage ¶
func (*Signin) ProtoMessage()
func (*Signin) ProtoReflect ¶
func (x *Signin) ProtoReflect() protoreflect.Message
type Signout ¶
type Signout struct {
// contains filtered or unexported fields
}
func (*Signout) Descriptor
deprecated
func (*Signout) ProtoMessage ¶
func (*Signout) ProtoMessage()
func (*Signout) ProtoReflect ¶
func (x *Signout) ProtoReflect() protoreflect.Message
type SignoutRes ¶
type SignoutRes struct { Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` // contains filtered or unexported fields }
func (*SignoutRes) Descriptor
deprecated
func (*SignoutRes) Descriptor() ([]byte, []int)
Deprecated: Use SignoutRes.ProtoReflect.Descriptor instead.
func (*SignoutRes) GetCode ¶
func (x *SignoutRes) GetCode() int32
func (*SignoutRes) ProtoMessage ¶
func (*SignoutRes) ProtoMessage()
func (*SignoutRes) ProtoReflect ¶
func (x *SignoutRes) ProtoReflect() protoreflect.Message
func (*SignoutRes) Reset ¶
func (x *SignoutRes) Reset()
func (*SignoutRes) String ¶
func (x *SignoutRes) String() string
type Signup ¶
type Signup struct { Auth *Auth `protobuf:"bytes,1,opt,name=auth,proto3" json:"auth,omitempty"` // contains filtered or unexported fields }
func (*Signup) Descriptor
deprecated
func (*Signup) ProtoMessage ¶
func (*Signup) ProtoMessage()
func (*Signup) ProtoReflect ¶
func (x *Signup) ProtoReflect() protoreflect.Message
type Token ¶
type Token struct { Token []byte `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` // contains filtered or unexported fields }
func (*Token) Descriptor
deprecated
func (*Token) ProtoMessage ¶
func (*Token) ProtoMessage()
func (*Token) ProtoReflect ¶
func (x *Token) ProtoReflect() protoreflect.Message
type TokenRes ¶
type TokenRes struct { Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` Id uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` Username string `protobuf:"bytes,3,opt,name=username,proto3" json:"username,omitempty"` Token []byte `protobuf:"bytes,4,opt,name=token,proto3" json:"token,omitempty"` // contains filtered or unexported fields }
func (*TokenRes) Descriptor
deprecated
func (*TokenRes) GetUsername ¶
func (*TokenRes) ProtoMessage ¶
func (*TokenRes) ProtoMessage()
func (*TokenRes) ProtoReflect ¶
func (x *TokenRes) ProtoReflect() protoreflect.Message
type User ¶
type User struct { Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` Online bool `protobuf:"varint,2,opt,name=online,proto3" json:"online,omitempty"` // contains filtered or unexported fields }
func (*User) Descriptor
deprecated
func (*User) GetUsername ¶
func (*User) ProtoMessage ¶
func (*User) ProtoMessage()
func (*User) ProtoReflect ¶
func (x *User) ProtoReflect() protoreflect.Message
type Users ¶
type Users struct {
// contains filtered or unexported fields
}
func (*Users) Descriptor
deprecated
func (*Users) ProtoMessage ¶
func (*Users) ProtoMessage()
func (*Users) ProtoReflect ¶
func (x *Users) ProtoReflect() protoreflect.Message
type UsersRes ¶
type UsersRes struct { Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` Users []*User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` // contains filtered or unexported fields }
func (*UsersRes) Descriptor
deprecated
func (*UsersRes) ProtoMessage ¶
func (*UsersRes) ProtoMessage()
func (*UsersRes) ProtoReflect ¶
func (x *UsersRes) ProtoReflect() protoreflect.Message
Click to show internal directories.
Click to hide internal directories.