Documentation ¶
Index ¶
- Constants
- Variables
- func DecryptData(buf []byte) []byte
- func EncryptData(buf []byte) []byte
- func PackMsg(msgid byte, flag byte, databuff []byte) []byte
- func PutRecvStream(sm Stream)
- func PutSendStream(sm Stream)
- func PutStream(sm Stream)
- func ReadMsg(reader io.Reader) (uint16, byte, byte, uint64, []byte, []byte, error)
- func WriteMsgHeader(msgid byte, flag byte, fid uint64, bs *stream.ByteStream)
- type IEntity
- type LoginRetMsg
- type MsgObj
- type RecvStream
- func (rs *RecvStream) DataSize() uint16
- func (rs *RecvStream) Decode() error
- func (rs *RecvStream) DecompressAndDecrypt() error
- func (rs *RecvStream) Decrypt() error
- func (rs *RecvStream) DestPeer() byte
- func (rs *RecvStream) Eid() uint64
- func (rs *RecvStream) Etype() uint16
- func (rs *RecvStream) Flag() byte
- func (rs *RecvStream) GetBuff() []byte
- func (rs *RecvStream) GetHeader() (destpeer byte, mid uint16, etype uint16, eid uint64)
- func (rs *RecvStream) Mid() uint16
- func (rs *RecvStream) ReadBool() (bool, error)
- func (rs *RecvStream) ReadByte() (byte, error)
- func (rs *RecvStream) ReadBytes() ([]byte, error)
- func (rs *RecvStream) ReadFloat32() (float32, error)
- func (rs *RecvStream) ReadFloat64() (float64, error)
- func (rs *RecvStream) ReadInt16() (int16, error)
- func (rs *RecvStream) ReadInt32() (int32, error)
- func (rs *RecvStream) ReadInt64() (int64, error)
- func (rs *RecvStream) ReadInt8() (int8, error)
- func (rs *RecvStream) ReadString() (string, error)
- func (rs *RecvStream) ReadUint16() (uint16, error)
- func (rs *RecvStream) ReadUint32() (uint32, error)
- func (rs *RecvStream) ReadUint64() (uint64, error)
- func (rs *RecvStream) ReadUint64s() ([]uint64, error)
- func (rs *RecvStream) Recv(r io.Reader) error
- func (rs *RecvStream) Reset()
- func (rs *RecvStream) SetHeader(destpeer byte, mid uint16, etype uint16, eid uint64)
- func (rs *RecvStream) String() string
- func (rs *RecvStream) UnSerializeArgs(funcref reflect.Value) ([]reflect.Value, error)
- type SendStream
- func (ss *SendStream) Clone() *SendStream
- func (ss *SendStream) CompressAndEncrypt() uint16
- func (ss *SendStream) Encode() error
- func (ss *SendStream) Encrypt() error
- func (ss *SendStream) GetBuff() []byte
- func (ss *SendStream) SerializeArgs(args ...interface{}) error
- func (ss *SendStream) SetDataSize(size uint16)
- func (ss *SendStream) SetDestPeer(destpeer byte)
- func (ss *SendStream) SetEid(eid uint64)
- func (ss *SendStream) SetEtype(etype uint16)
- func (ss *SendStream) SetFlag(flag byte)
- func (ss *SendStream) SetHeader(destpeer byte, mid, etype uint16, eid uint64)
- func (ss *SendStream) SetMid(msgid uint16)
- func (ss *SendStream) String() string
- func (ss *SendStream) WriteBool(v bool) error
- func (ss *SendStream) WriteByte(v byte) error
- func (ss *SendStream) WriteBytes(v []byte) error
- func (ss *SendStream) WriteFloat32(f float32) error
- func (ss *SendStream) WriteFloat64(f float64) error
- func (ss *SendStream) WriteInt16(v int16) error
- func (ss *SendStream) WriteInt32(v int32) error
- func (ss *SendStream) WriteInt64(v int64) error
- func (ss *SendStream) WriteInt8(v int8) error
- func (ss *SendStream) WriteString(v string) error
- func (ss *SendStream) WriteUint16(v uint16) error
- func (ss *SendStream) WriteUint32(v uint32) error
- func (ss *SendStream) WriteUint64(v uint64) error
- func (ss *SendStream) WriteUint64s(v []uint64) error
- func (ss *SendStream) WriteUint8(v uint8) error
- type Stream
- type UserTokenInfo
Constants ¶
View Source
const ( MsgId_Login byte = iota MsgId_LoginRet //1 MsgId_CreateEntity //2 MsgId_RemoveEntity //3 MsgId_EntityMsg //4 MsgId_EntityRPCMsg //5 MsgId_SrvMsg //6 MsgId_ClientMsg //7 MsgId_Tick //8 MsgId_Error //9 MsgId_SyncEntity //10 MsgId_ServerInfo //11 MsgId_NewClientPeer //12 MsgId_SetClientPeerId //13 MsgId_PublicEntityMsg //4 MsgId_PublicEntityRPCMsg //4 MsgId_RemoteCall //4 )
View Source
const ( ERRCODE_NONE uint16 = iota ERRCODE_NOT_LOGIN ERRCODE_ERR_LOGIN ERRCODE_ERR_PASSWORD ERRCODE_ERR_REDIS ERRCODE_TOKEN_NOT_EXISTS ERRCODE_CREATE_ENTITY_FAILED ERRCODE_ALREADY_EXISTS )
View Source
const HeaderSize = 16
View Source
const MaxSize = 1 << 13
MaxSize is the supported maximum size
Variables ¶
View Source
var EtypeVerifyMap map[uint16]uint16
View Source
var MidVerifyMap map[uint16]uint16
Functions ¶
func PutRecvStream ¶
func PutRecvStream(sm Stream)
func PutSendStream ¶
func PutSendStream(sm Stream)
func ReadMsg ¶
return (size, flag, msgid, fid, databuff, rawbuff, err) 可以优化这边的读取,读取到一个大的buff中 1.先读取headerSize个字节到buff中,然后解析出header 2.根据解析出来的数据size,将数据读取到buff中
func WriteMsgHeader ¶
func WriteMsgHeader(msgid byte, flag byte, fid uint64, bs *stream.ByteStream)
Types ¶
type IEntity ¶
type IEntity interface { ID() uint64 RegisterMethodId(id uint16, processer func(bs *RecvStream) error) //ForwardMsg(data []byte) error //ProcessMethod(id uint16, bs *RecvStream) error ProcessRpc(bs *RecvStream) error Marshal(bs *SendStream) error Unmarshal(bs *RecvStream) error }
type LoginRetMsg ¶
type LoginRetMsg struct { ErrorDesc string `json:"error,omitempty"` ErrorCode uint16 `json:"errorcode"` Eid uint64 `json:"eid,string"` PeerId uint64 `json:"peerid,string"` SrvPeerId uint64 `json:"srvpeerid,string"` SrvPeerType byte `json:"srvpeertype"` Uid uint64 `json:"uid,string"` Account string `json:"account,omitempty"` SrvAddr string `json:"srvaddr,omitempty"` Token string `json:"token,omitempty"` }
type MsgObj ¶
type MsgObj struct { Id uint64 MsgId byte MsgSize int16 SerializeFunc func(*SendStream) }
type RecvStream ¶
type RecvStream struct {
// contains filtered or unexported fields
}
func GetRecvStream ¶
func GetRecvStream(size uint16) *RecvStream
func (*RecvStream) DataSize ¶
func (rs *RecvStream) DataSize() uint16
func (*RecvStream) Decode ¶
func (rs *RecvStream) Decode() error
func (*RecvStream) DecompressAndDecrypt ¶
func (rs *RecvStream) DecompressAndDecrypt() error
func (*RecvStream) Decrypt ¶
func (rs *RecvStream) Decrypt() error
func (*RecvStream) DestPeer ¶
func (rs *RecvStream) DestPeer() byte
func (*RecvStream) Eid ¶
func (rs *RecvStream) Eid() uint64
func (*RecvStream) Etype ¶
func (rs *RecvStream) Etype() uint16
func (*RecvStream) Flag ¶
func (rs *RecvStream) Flag() byte
func (*RecvStream) GetBuff ¶
func (rs *RecvStream) GetBuff() []byte
func (*RecvStream) GetHeader ¶
func (rs *RecvStream) GetHeader() (destpeer byte, mid uint16, etype uint16, eid uint64)
func (*RecvStream) Mid ¶
func (rs *RecvStream) Mid() uint16
func (*RecvStream) ReadBytes ¶
func (rs *RecvStream) ReadBytes() ([]byte, error)
ReadBytes 读取一个byte[]
func (*RecvStream) ReadFloat32 ¶
func (rs *RecvStream) ReadFloat32() (float32, error)
ReadFloat32 读取float32
func (*RecvStream) ReadFloat64 ¶
func (rs *RecvStream) ReadFloat64() (float64, error)
ReadFloat64 读取float64
func (*RecvStream) ReadString ¶
func (rs *RecvStream) ReadString() (string, error)
ReadString 读取一个string
func (*RecvStream) ReadUint16 ¶
func (rs *RecvStream) ReadUint16() (uint16, error)
ReadUInt16 读取一个UInt16
func (*RecvStream) ReadUint32 ¶
func (rs *RecvStream) ReadUint32() (uint32, error)
ReadUInt32 读取一个Int
func (*RecvStream) ReadUint64 ¶
func (rs *RecvStream) ReadUint64() (uint64, error)
ReadUInt64 读取一个Uint64
func (*RecvStream) ReadUint64s ¶
func (rs *RecvStream) ReadUint64s() ([]uint64, error)
func (*RecvStream) Reset ¶
func (rs *RecvStream) Reset()
func (*RecvStream) SetHeader ¶
func (rs *RecvStream) SetHeader(destpeer byte, mid uint16, etype uint16, eid uint64)
func (*RecvStream) String ¶
func (rs *RecvStream) String() string
func (*RecvStream) UnSerializeArgs ¶
type SendStream ¶
type SendStream struct {
// contains filtered or unexported fields
}
func GetDefaultSendStream ¶
func GetDefaultSendStream() *SendStream
func GetSendStream ¶
func GetSendStream(size uint16) *SendStream
func (*SendStream) Clone ¶
func (ss *SendStream) Clone() *SendStream
func (*SendStream) CompressAndEncrypt ¶
func (ss *SendStream) CompressAndEncrypt() uint16
func (*SendStream) Encode ¶
func (ss *SendStream) Encode() error
func (*SendStream) Encrypt ¶
func (ss *SendStream) Encrypt() error
func (*SendStream) GetBuff ¶
func (ss *SendStream) GetBuff() []byte
func (*SendStream) SerializeArgs ¶
func (ss *SendStream) SerializeArgs(args ...interface{}) error
func (*SendStream) SetDataSize ¶
func (ss *SendStream) SetDataSize(size uint16)
func (*SendStream) SetDestPeer ¶
func (ss *SendStream) SetDestPeer(destpeer byte)
func (*SendStream) SetEid ¶
func (ss *SendStream) SetEid(eid uint64)
func (*SendStream) SetEtype ¶
func (ss *SendStream) SetEtype(etype uint16)
func (*SendStream) SetFlag ¶
func (ss *SendStream) SetFlag(flag byte)
func (*SendStream) SetHeader ¶
func (ss *SendStream) SetHeader(destpeer byte, mid, etype uint16, eid uint64)
func (*SendStream) SetMid ¶
func (ss *SendStream) SetMid(msgid uint16)
func (*SendStream) String ¶
func (ss *SendStream) String() string
func (*SendStream) WriteBool ¶
func (ss *SendStream) WriteBool(v bool) error
WriteBool 写bool, 1代表true, 0代表false
func (*SendStream) WriteFloat32 ¶
func (ss *SendStream) WriteFloat32(f float32) error
WriteFloat32 写Float32
func (*SendStream) WriteFloat64 ¶
func (ss *SendStream) WriteFloat64(f float64) error
WriteFloat64 写Float64
func (*SendStream) WriteString ¶
func (ss *SendStream) WriteString(v string) error
WriteString 写string
func (*SendStream) WriteUint16 ¶
func (ss *SendStream) WriteUint16(v uint16) error
WriteUInt16 写Uint16
func (*SendStream) WriteUint32 ¶
func (ss *SendStream) WriteUint32(v uint32) error
WriteUInt32 写Uint32
func (*SendStream) WriteUint64 ¶
func (ss *SendStream) WriteUint64(v uint64) error
WriteUInt64 写Uint64
func (*SendStream) WriteUint64s ¶
func (ss *SendStream) WriteUint64s(v []uint64) error
func (*SendStream) WriteUint8 ¶
func (ss *SendStream) WriteUint8(v uint8) error
Click to show internal directories.
Click to hide internal directories.