mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 02:31:04 +01:00
add more websocket helpers from neffos project
Former-commit-id: fcb9ec46849fd745fe0f62524d9b85067a334048
This commit is contained in:
parent
c93093d6c2
commit
164f24dec4
|
@ -42,7 +42,7 @@ func main() {
|
|||
ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(dialAndConnectTimeout))
|
||||
defer cancel()
|
||||
|
||||
client, err := websocket.Dial(ctx, websocket.GorillaDialer, endpoint, clientEvents)
|
||||
client, err := websocket.Dial(ctx, websocket.DefaultGorillaDialer, endpoint, clientEvents)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -28,10 +28,17 @@ var (
|
|||
// See examples for more.
|
||||
New = neffos.New
|
||||
|
||||
// GorillaDialer is a gorilla/websocket dialer with all fields set to the default values.
|
||||
GorillaDialer = gorilla.DefaultDialer
|
||||
// GobwasDialer is a gobwas/ws dialer with all fields set to the default values.
|
||||
GobwasDialer = gobwas.DefaultDialer
|
||||
// GorillaDialer is a `Dialer` type for the gorilla/websocket subprotocol implementation.
|
||||
// Should be used on `Dial` to create a new client/client-side connection.
|
||||
GorillaDialer = gorilla.Dialer
|
||||
// GobwasDialer is a `Dialer` type for the gobwas/ws subprotocol implementation.
|
||||
// Should be used on `Dial` to create a new client/client-side connection.
|
||||
GobwasDialer = gobwas.Dialer
|
||||
|
||||
// DefaultGorillaDialer is a gorilla/websocket dialer with all fields set to the default values.
|
||||
DefaultGorillaDialer = gorilla.DefaultDialer
|
||||
// DefaultGobwasDialer is a gobwas/ws dialer with all fields set to the default values.
|
||||
DefaultGobwasDialer = gobwas.DefaultDialer
|
||||
// Dial establishes a new websocket client connection.
|
||||
// Context "ctx" is used for handshake timeout.
|
||||
// Dialer "dial" can be either `GorillaDialer` or `GobwasDialer`,
|
||||
|
|
|
@ -4,15 +4,25 @@ package websocket
|
|||
|
||||
import (
|
||||
"github.com/kataras/neffos"
|
||||
"github.com/kataras/neffos/gobwas"
|
||||
"github.com/kataras/neffos/gorilla"
|
||||
)
|
||||
|
||||
type (
|
||||
// Dialer is the definition type of a dialer, gorilla or gobwas or custom.
|
||||
// It is the second parameter of the `Dial` function.
|
||||
Dialer = neffos.Dialer
|
||||
// GorillaDialerOptions is just an alias for the `gobwas/ws.Dialer` struct type.
|
||||
GorillaDialerOptions = gorilla.Options
|
||||
// GobwasDialerOptions is just an alias for the `gorilla/websocket.Dialer` struct type.
|
||||
GobwasDialerOptions = gobwas.Options
|
||||
|
||||
// Conn describes the main websocket connection's functionality.
|
||||
// Its `Connection` will return a new `NSConn` instance.
|
||||
// Each connection can connect to one or more declared namespaces.
|
||||
// Each `NSConn` can join to multiple rooms.
|
||||
Conn = neffos.Conn
|
||||
// NSConn describes a connected connection to a specific namespace,
|
||||
// NSConn describes a connection connected to a specific namespace,
|
||||
// it emits with the `Message.Namespace` filled and it can join to multiple rooms.
|
||||
// A single `Conn` can be connected to one or more namespaces,
|
||||
// each connected namespace is described by this structure.
|
||||
|
|
Loading…
Reference in New Issue
Block a user