Upgraders & Dialers

Neffos should run behind a low-level websocket implementation for Go. The developer has full control of this, to use her/his own or wrap an existing one. Neffos comes with two built-in low-level websocket implementations for Upgrading incoming http connections or Dialing the websocket server through Go (note that neffos provides clients for Nodejs & Browser too, see the neffos.js project to learn about). Those two optional dependencies are downloaded automatically for you on the Installation process.

  1. github.com/gorilla/websocket

    • When server wants to Upgrade using gorilla/websocket.Upgrader or when a client wants to dial using the gorilla/websocket.Dialer.

  2. github.com/gobwas/ws

    • When server wants to Upgrade using gobwas/ws.HTTPUpgrader or when a client wants to dial using the gobwas/ws.Dialer.

Neffos provides an easy way to adapt those through the following sub-packages:

  1. github.com/kataras/neffos/gorilla

    • DefaultUpgrader

    • Upgrader(websocket.Upgrader) neffos.Upgrader

    • DefaultDialer

    • Dialer(dialer *websocket.Dialer, requestHeader http.Header) neffos.Dialer

  2. github.com/kataras/neffos/gobwas

    • DefaultUpgrader

    • Upgrader(upgrader ws.HTTPUpgrader) neffos.Upgrader

    • DefaultDialer

    • Dialer(dialer ws.Dialer) neffos.Dialer

However, it is possible to wrap an existing one or implement your own and pass it to a neffos server and/or neffos client.

The neffos.New accepts a neffos.Upgrader.

The neffos.Dial accepts a neffos.Dialer.

Both Upgrader and Dialer should return a valid neffos.Socket.

Usage

Last updated