RSSAmplifier

Some Random Remarks on seehuhn.de · Jan 16, 2025

go-websocket

0
Sign in to vote or save

seehuhn.de

A GPL-licensed WebSocket server written in Go

Introduction

go-websocket is a GPL-licensed WebSocket server implementation written in Go. The library provides a simple HTTP handler that facilitates WebSocket connections, making it easy to add real-time bidirectional communication to Go applications.

The project is available on GitHub and is released under the GPL-3.0 license.

Features

  • Simple API: Straightforward HTTP handler for initiating WebSocket connections
  • Bidirectional Communication: Support for sending and receiving messages
  • Handler-Based: Uses a callback function approach to process client connections
  • Easy Integration: Works seamlessly with Go’s standard HTTP server

Installation

To install go-websocket, use:

go get seehuhn.de/go/websocket

Usage

The library uses a websocket.Handler object to manage connections. Developers define a callback function that processes each client connection, handling message reception and transmission through reader/writer interfaces.

Example of a simple echo server:

import "seehuhn.de/go/websocket"

handler := websocket.Handler(func(conn *websocket.Conn) {
    // Handle incoming messages and send responses
    // Messages received from clients are reflected back
})

Documentation

Full API documentation is available on godoc.org or through the command line:

go doc seehuhn.de/go/websocket

The source code is available on github.com/seehuhn/go-websocket.

Source Code

View on GitHub: seehuhn/go-websocket

Read the original on seehuhn.de

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.