engine.io-parser

workflow Coverage Status GoDoc License

This is the GO parser version 4 for the engine.io protocol encoding.

Installation

Use go get.

go get github.com/funcards/engine.io-parser/v4

Then import the validator package into your own code.

import "github.com/funcards/engine.io-parser/v4"

How to use

The parser can encode/decode packets, payloads and payloads as binary.

Example:

var buf bytes.Buffer

payload := eio_parser.Payload{
    Packets: []eio_parser.Packet{
        {Type: eio_parser.PacketTypeOpen},
        {Type: eio_parser.PacketTypeClose},
        {Type: eio_parser.PacketTypePing, Data: "probe"},
        {Type: eio_parser.PacketTypePong, Data: "probe"},
        {Type: eio_parser.PacketTypeMessage, Data: "test"},
    },
}
payload.Encode(&buf)
fmt.Println(buf.Bytes())

payload1 = eio_parser.Payload{}
payload1.Decode(&buf) // payload == payload1

License

Distributed under MIT License, please see license file within the code for more details.

GitHub

View Github