engine.io packet parser for golang.
MIT License
This is the golang parser for the engine.io protocol encoding, shared by both engine.io-client-go(not ready) and engine.io.
The parser can encode/decode packets, payloads, and payloads as binary
with the following methods: Parser.EncodePacket
, Parser.DecodePacket
, Parser.EncodePayload
,
Parser.DecodePayload
.
Example:
import (
"bytes"
"io"
"strings"
"github.com/zishang520/engine.io-go-parser/packet"
"github.com/zishang520/engine.io-go-parser/types"
)
func main() {
p := &packet.Parserv4()
data, _ := p.EncodePacket(&packet.Packet{
Type: packet.MESSAGE,
Data: bytes.NewBuffer([]byte{1, 2, 3, 4}),
Options: nil,
}, true)
decodedData, _ := p.DecodePacket(data)
}
EncodePacket
*packet.Packet
: the packet to encode.bool
: binary support.bool
: utf8 encode, v3 only.DecodePacket
types.BufferInterface
: the packet to decode.bool
: utf8 encode, v3 only.EncodePayload
[]*packet.Packet
: an array of packetsbool
: binary support, v3 only.DecodePayload
types.BufferInterface
: the payloadStandalone tests can be run with make test
which will run the golang tests.
You can run the tests locally using the following command:
make test
To contribute patches, run tests or benchmarks, make sure to clone the repository:
git clone git://github.com/zishang520/engine.io-go-parser.git
Then:
cd engine.io-go-parser
make test
See the Tests
section above for how to run tests before submitting any patches.
MIT