websocket

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

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

Go to latest
Published: Aug 12, 2019 License: MIT Imports: 2 Imported by: 0

README

websocket

godoc goreportcard

Install

go get -u github.com/117/websocket

Usage
Creating a new client.
client, err := websocket.NewClient(websocket.Settings{
    URL: "wss://example.com",
})
Sending a message.
err := client.Send("hey this is a message")
Receiving a message
message, err := client.Receive() // blocking, use for{} to receive continuously
Contribute

Pull requests are encouraged.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client - A bare bones websocket client.

func NewClient

func NewClient(settings Settings) (*Client, error)

NewClient - Creates a client and attempts to establish connection.

func (*Client) Connect

func (client *Client) Connect() error

Connect - Attempt a new connection to a websocket.

func (*Client) Receive

func (client *Client) Receive(message interface{}) error

Receive - Block until a new message is received, provide a JSON-friendly pointer.

func (*Client) ReceiveBytes

func (client *Client) ReceiveBytes() ([]byte, error)

ReceiveBytes - Block until a new message is received.

func (*Client) Send

func (client *Client) Send(message interface{}) error

Send - Using the existing socket, send a new message. Use a JSON-friendly struct.

func (*Client) SendBytes

func (client *Client) SendBytes(bytes []byte) error

SendBytes - Using the existing socket, send a new message.

type Settings

type Settings struct {
	// The websocket server URL.
	URL string
}

Settings -

Jump to

Keyboard shortcuts

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