An open API service indexing awesome lists of open source software.

https://github.com/icarephone/websocket

Gorilla WebSocket implementation for fasthttp.
https://github.com/icarephone/websocket

go websocket

Last synced: 5 months ago
JSON representation

Gorilla WebSocket implementation for fasthttp.

Awesome Lists containing this project

README

          

# Fasthttp Gorilla WebSocket

[![Build Status](https://travis-ci.org/fasthttp/websocket.svg?branch=master)](https://travis-ci.org/fasthttp/websocket)
[![Go Report Card](https://goreportcard.com/badge/github.com/icarephone/websocket)](https://goreportcard.com/report/github.com/icarephone/websocket)
[![GoDev](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white)](https://pkg.go.dev/github.com/icarephone/websocket)
[![GitHub release](https://img.shields.io/github/release/fasthttp/websocket.svg)](https://github.com/icarephone/websocket/releases)

[Gorilla WebSocket](https://github.com/gorilla/websocket) is a [Go](http://golang.org/) implementation of the
[WebSocket](http://www.rfc-editor.org/rfc/rfc6455.txt) protocol.

This fork adds [fasthttp](https://github.com/valyala/fasthttp) support to the latest version of [gorilla/websocket](https://github.com/gorilla/websocket).

### Documentation

* [API Reference](https://pkg.go.dev/github.com/icarephone/websocket?tab=doc)
* [Chat example](_examples/chat)
* [Command example](_examples/command)
* [Client and server example](_examples/echo)
* [File watch example](_examples/filewatch)

### Status

The Gorilla WebSocket package provides a complete and tested implementation of
the [WebSocket](http://www.rfc-editor.org/rfc/rfc6455.txt) protocol. The
package API is stable.

### Installation

```
go get github.com/icarephone/websocket
```
But beware that this will fetch the **latest commit of the master branch** which is never purposely broken, but usually not considered stable anyway.

#### Dep
If you're using [dep](https://github.com/golang/dep), just use `dep ensure` to add
a specific version of fasthttp/websocket including all its transitive dependencies to
your project:
```
dep ensure -add github.com/icarephone/websocket@v1.4.0
```

**IMPORTANT:** [dep](https://github.com/golang/dep) is only supported until version v1.4.0. In future versions will use Go modules.

### Protocol Compliance

The Gorilla WebSocket package passes the server tests in the [Autobahn Test
Suite](https://github.com/crossbario/autobahn-testsuite) using the application in the [examples/autobahn
subdirectory](_examples/autobahn).

### Gorilla WebSocket compared with other packages

github.com/fasthttp
golang.org/x/net

RFC 6455 Features
Passes Autobahn Test SuiteYesNo
Receive fragmented messageYesNo, see note 1
Send close messageYesNo
Send pings and receive pongsYesNo
Get the type of a received data messageYesYes, see note 2
Other Features
Compression ExtensionsExperimentalNo
Read message using io.ReaderYesNo, see note 3
Write message using io.WriteCloserYesNo, see note 3

Notes:

1. Large messages are fragmented in [Chrome's new WebSocket implementation](http://www.ietf.org/mail-archive/web/hybi/current/msg10503.html).
2. The application can get the type of a received data message by implementing
a [codec marshal](http://godoc.org/golang.org/x/net/websocket#Codec.Marshal)
function.
3. The [go/net](https://golang.org/pkg/net/) `io.Reader` and `io.Writer` operate across WebSocket frame boundaries.
Read returns when the input buffer is full or a frame boundary is
encountered. Each call to Write sends a single frame message. The Gorilla
`io.Reader` and `io.WriteCloser` operate on a single WebSocket message.