socketio

package module
v0.0.0-...-3768181 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2024 License: MIT Imports: 16 Imported by: 0

README

go-socket.io-client

socket.io client for go. Support EIO4.

Install

Install the package with:

go get github.com/mark0725/go-socket.io-client

Import it with:

import "github.com/mark0725/go-socket.io-client"

and use socketio as the package name inside the code.

Example

License

MIT

Documentation

Index

Constants

View Source
const (
	DefaultCloseTxt  = "transport close"
	DefaultCloseCode = 101
)
View Source
const (
	OnMessage       = "message"
	OnConnection    = "connection"
	OnDisconnection = "disconnection"
	OnError         = "error"
)

Variables

View Source
var (
	ErrorCallerNotFunc       = errors.New("f is not function")
	ErrorCallerMaxFiveArgs   = errors.New("f maximum number of args is 5")
	ErrorCallerMaxFiveValues = errors.New("f maximum number of values is 5")
)
View Source
var (
	ErrorSendTimeout     = errors.New("timeout")
	ErrorSocketOverflood = errors.New("socket overflood")
)
View Source
var (
	ErrorWaiterNotFound = errors.New("Waiter not found")
)
View Source
var (
	ErrorWrongHeader = errors.New("Wrong header")
)

Functions

func SchedulePing

func SchedulePing(c *Channel)

Types

type Channel

type Channel struct {
	// contains filtered or unexported fields
}

* socket.io connection handler

use IsAlive to check that handler is still working use Dial to connect to websocket use In and Out channels for message exchange Close message means channel is closed ping is automatic

func (*Channel) Ack

func (c *Channel) Ack(method string, timeout time.Duration, args ...interface{}) (interface{}, error)

func (*Channel) BinaryMessage

func (c *Channel) BinaryMessage() bool

func (*Channel) Emit

func (c *Channel) Emit(method string, args ...interface{}) error

func (*Channel) Id

func (c *Channel) Id() string

func (*Channel) IsAlive

func (c *Channel) IsAlive() bool

* Checks that Channel is still alive

func (*Channel) LocalAddr

func (c *Channel) LocalAddr() net.Addr

func (*Channel) ReadBytes

func (c *Channel) ReadBytes() int

func (*Channel) RemoteAddr

func (c *Channel) RemoteAddr() net.Addr

func (*Channel) WriteBytes

func (c *Channel) WriteBytes() int

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(addr string, opts *ClientOptions) (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) Emit

func (c *Client) Emit(method string, args ...interface{}) error

func (*Client) On

func (c *Client) On(method string, f interface{}) error

type ClientBuilder

type ClientBuilder struct{}

func (*ClientBuilder) Build

func (c *ClientBuilder) Build(addr string, opts ...ClientOption) (*Client, error)

func (*ClientBuilder) WithAuth

func (c *ClientBuilder) WithAuth(v map[string]string) ClientOption

func (*ClientBuilder) WithIOOpts

func (c *ClientBuilder) WithIOOpts(v map[string]string) ClientOption

func (*ClientBuilder) WithNamespace

func (c *ClientBuilder) WithNamespace(v string) ClientOption

func (*ClientBuilder) WithPath

func (c *ClientBuilder) WithPath(v string) ClientOption

type ClientOption

type ClientOption func(*ClientOptions)

type ClientOptions

type ClientOptions struct {
	Namespace string
	Path      string
	Auth      map[string]string
}
type Header struct {
	Sid          string   `json:"sid"`
	Upgrades     []string `json:"upgrades"`
	PingInterval int      `json:"pingInterval"`
	PingTimeout  int      `json:"pingTimeout"`
}

* engine.io header to send or receive

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL