Documentation
¶
Index ¶
- Constants
- Variables
- func ArgumentTypeName(argumentType ArgumentType) string
- func BindArguments(arguments []Argument, expected []reflect.Type) ([]any, error)
- func BindArgumentsWithTransfers(arguments []Argument, expected []reflect.Type, files map[uint64]gox.File) ([]any, error)
- func DecodeBigInt(data []byte) (*big.Int, error)
- func DecodeCompactUint(data []byte) (uint64, int, error)
- func DecodeFileReference(data []byte) (uint64, error)
- func DecodeFilesReference(data []byte) ([]uint64, error)
- func EncodeArguments(arguments []Argument) ([]byte, error)
- func EncodeBigInt(value *big.Int) ([]byte, error)
- func EncodeCompactUint(value uint64) []byte
- func EncodeFileReference(transferID uint64) ([]byte, error)
- func EncodeFilesReference(transferIDs []uint64) ([]byte, error)
- func EncodePacket(packet Packet) ([]byte, error)
- func EncodeValuesWithTransfers(values []any, allocate func() uint64, clients ...gox.ClientIslandRuntime) ([]Argument, []Transfer, error)
- func EventName(packet Packet) string
- func HeaderText(packet Packet, headerType HeaderType) string
- func HeaderUint(packet Packet, headerType HeaderType) (uint64, bool)
- type Argument
- type ArgumentType
- type BindingError
- type Header
- type HeaderType
- type Packet
- type PacketType
- type Transfer
Constants ¶
const ( ImportSpecifier = "@gox/websocket" ClientPath = "/_gox/websocket/client.js" HandshakePath = "/_gox/websocket/handshake" )
const ( FlagInternal byte = 1 << 0 FlagTransfer byte = 1 << 1 )
const ProtocolVersion byte = 0x01
Variables ¶
var ClientSource []byte
ClientSource is the JavaScript module served from ClientPath.
var ErrMalformedPacket = errors.New("malformed GOX WebSocket packet")
Functions ¶
func ArgumentTypeName ¶
func ArgumentTypeName(argumentType ArgumentType) string
func BindArguments ¶
func DecodeBigInt ¶
DecodeBigInt decodes one canonical BIGINT argument without limiting its precision to uint64.
func DecodeCompactUint ¶
DecodeCompactUint decodes one canonical compact uint and returns how many bytes were consumed.
func DecodeFileReference ¶
func DecodeFilesReference ¶
func EncodeArguments ¶
func EncodeBigInt ¶
EncodeBigInt creates the canonical decimal payload of one BIGINT argument.
func EncodeCompactUint ¶
EncodeCompactUint encodes a uint64 as a width byte followed by the minimum number of big-endian bytes. Zero is encoded as one zero byte.
func EncodeFileReference ¶
EncodeFileReference creates the payload of one FILE argument.
func EncodeFilesReference ¶
EncodeFilesReference creates the payload of one FILES argument while preserving the original file order.
func EncodePacket ¶
func EncodeValuesWithTransfers ¶
func EncodeValuesWithTransfers(values []any, allocate func() uint64, clients ...gox.ClientIslandRuntime) ([]Argument, []Transfer, error)
EncodeValuesWithTransfers encodes event values and extracts file bodies into independent transfers referenced by FILE and FILES arguments.
func HeaderText ¶
func HeaderText(packet Packet, headerType HeaderType) string
func HeaderUint ¶
func HeaderUint(packet Packet, headerType HeaderType) (uint64, bool)
Types ¶
type Argument ¶
type Argument struct {
Type ArgumentType
Data []byte
}
func DecodeArguments ¶
func EncodeValue ¶
func EncodeValue(value any, clients ...gox.ClientIslandRuntime) (Argument, error)
EncodeValue converts one server value into its stable wire category.
func EncodeValues ¶
type ArgumentType ¶
type ArgumentType byte
const ( ArgumentNull ArgumentType = 0x00 ArgumentText ArgumentType = 0x01 ArgumentNumber ArgumentType = 0x02 ArgumentBoolean ArgumentType = 0x03 ArgumentDate ArgumentType = 0x04 ArgumentJSON ArgumentType = 0x05 ArgumentBinary ArgumentType = 0x06 ArgumentFile ArgumentType = 0x07 ArgumentFiles ArgumentType = 0x08 ArgumentBigInt ArgumentType = 0x09 ArgumentHTML ArgumentType = 0x0a )
type BindingError ¶
func (*BindingError) Error ¶
func (err *BindingError) Error() string
func (*BindingError) Unwrap ¶
func (err *BindingError) Unwrap() error
type Header ¶
type Header struct {
Type HeaderType
Value []byte
}
type HeaderType ¶
type HeaderType byte
const ( HeaderEventName HeaderType = 0x01 HeaderRequestID HeaderType = 0x02 HeaderTransferID HeaderType = 0x03 HeaderSequence HeaderType = 0x04 HeaderTotalSize HeaderType = 0x05 HeaderFileName HeaderType = 0x06 HeaderMIMEType HeaderType = 0x07 HeaderErrorCode HeaderType = 0x08 HeaderEventID HeaderType = 0x09 HeaderChannelID HeaderType = 0x0a HeaderChannelReason HeaderType = 0x0b )
type Packet ¶
type Packet struct {
Type PacketType
Flags byte
Headers []Header
Arguments []Argument
Payload []byte
}
func DecodePacket ¶
type PacketType ¶
type PacketType byte
const ( PacketEvent PacketType = 0x01 PacketRequest PacketType = 0x02 PacketResponse PacketType = 0x03 PacketError PacketType = 0x04 PacketTransferBegin PacketType = 0x10 PacketTransferChunk PacketType = 0x11 PacketTransferEnd PacketType = 0x12 PacketTransferAbort PacketType = 0x13 PacketChannelJoin PacketType = 0x20 PacketChannelAccepted PacketType = 0x21 PacketChannelRejected PacketType = 0x22 PacketChannelLeave PacketType = 0x23 PacketChannelEvent PacketType = 0x24 PacketChannelRequest PacketType = 0x25 PacketChannelResponse PacketType = 0x26 PacketChannelError PacketType = 0x27 )