Skip to content
A high performance websocket that uses netpoll with read and write concurrency to allow a high number of concurrent websocket connections.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
channel.go
go.mod
go.sum
handler.go
pool.go

README.md

Concurrent Websocket - Golang

A high performance websocket implementation that uses netpoll with read and write concurrency to allow a high number of concurrent websocket connections.

Prerequisite

Requires Go 1.11 or later, because of the usage of modules.

Quick start

# assume the following codes in example.go file
$ cat example.go
package main

import (
    "github.com/gin-gonic/gin"
    "github.com/blakerouse/concurrent-websocket"
)

func main() {
    r := gin.Default()

    concurrency := 128
    echo := func(c *websocket.Channel, op websocket.OpCode, data []byte) {
        // echo
        c.Send(op, data)
    }

    wh, _ := websocket.NewHandler(echo, concurrency, concurrency)
    r.GET("/ws", gin.WrapF(wh.UpgradeHandler))

    r.Run() // listen and serve on 0.0.0.0:8080
}
# run example.go and visit 0.0.0.0:8080/ping on browser
$ go run example.go
You can’t perform that action at this time.