Skip to content

zishang520/engine.io-client-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Engine.IO Client for Go

Build Status Go Reference

A robust Go client implementation for Engine.IO, the reliable real-time bidirectional communication layer that powers Socket.IO.

Features

  • Haven't written it yet.

Installation

go get github.com/zishang520/engine.io-client-go

Quick Start

Basic Usage

package main

import (
    "log"
    "time"
    eio "github.com/zishang520/engine.io-client-go/engine"
    "github.com/zishang520/engine.io/v2/utils"
    "github.com/zishang520/engine.io/v2/types"
)

func main() {
    socket := eio.NewSocket("ws://localhost", nil)
    
    socket.On("open", func(args ...any) {
        log.Println("Connection established")
        
        // Send a message after 1 second
        utils.SetTimeout(func() {
            socket.Send(types.NewStringBufferString("Hello, Server!"), nil, nil)
        }, 1*time.Second)
    })

    socket.On("message", func(args ...any) {
        log.Printf("Received message: %v", args[0])
    })

    socket.On("close", func(args ...any) {
        log.Println("Connection closed")
    })
}

Advanced Configuration

package main

import (
    "github.com/zishang520/engine.io-client-go/engine"
    "github.com/zishang520/engine.io-client-go/transports"
    "github.com/zishang520/engine.io/v2/types"
)

func main() {
    // Create custom socket options
    opts := engine.DefaultSocketOptions()
    
    // Configure connection settings
    opts.SetPath("/engine.io")
    opts.SetQuery(map[string][]string{
        "token": {"abc123"},
    })
    
    // Specify preferred transports
    opts.SetTransports(types.NewSet(
        transports.WebSocket,
        transports.Polling,
    ))
    
    // Configure timeouts
    opts.SetRequestTimeout(time.Second * 10)
    
    // Create socket with custom options
    socket := engine.NewSocket("ws://localhost", opts)
    
    // Handle events
    socket.On("open", func(args ...any) {
        // Connection established
    })
}

Development

Running Tests

git clone https://github.com/zishang520/engine.io-client-go.git
cd engine.io-client-go
go test ./...

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License

Copyright (c) 2025 luoyy

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Related Projects

About

engine.io-client for golang, start your happy journey! πŸ˜€

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages