connection

package
v0.0.0-...-bc28a72 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

This package holds the connection interface implementations to be used by project

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OptimizedRequestHandler

func OptimizedRequestHandler(context *gin.Context)

OptimizedRequestHandler - Optimized version of WebSocket handshake

func RequestHandler

func RequestHandler(context *gin.Context)

RequestHandler - Default WebSocket handler

Types

type OWebSocketConnection

type OWebSocketConnection struct {
	// contains filtered or unexported fields
}

OWebSocketConnection - O stands for optimized Implementation of the Connection interface for WebSocket clients

func (*OWebSocketConnection) Close

func (connection *OWebSocketConnection) Close()

Close - Close the current connection

func (*OWebSocketConnection) Init

func (connection *OWebSocketConnection) Init(ws net.Conn)

Init - Initialize connection and start reading and writing messages

func (*OWebSocketConnection) IsConnected

func (connection *OWebSocketConnection) IsConnected() bool

IsConnected - If connection is still alive

func (*OWebSocketConnection) Send

func (connection *OWebSocketConnection) Send(data []byte)

Send - Send the data to the client

func (*OWebSocketConnection) SendText

func (connection *OWebSocketConnection) SendText(data []byte)

SendText - Send the data to the client

func (*OWebSocketConnection) SetOnClose

func (connection *OWebSocketConnection) SetOnClose(cb func())

SetOnClose - Set on closed connection handler

func (*OWebSocketConnection) SetOnHeartBeat

func (connection *OWebSocketConnection) SetOnHeartBeat(cb func())

func (*OWebSocketConnection) SetOnMessage

func (connection *OWebSocketConnection) SetOnMessage(cb func([]byte))

SetOnMessage - Set user sent message callback

type SSEConnection

type SSEConnection struct {
	// contains filtered or unexported fields
}

SSEConnection - Implementation of the Connection interface for Server Sent Event clients

func (*SSEConnection) Close

func (connection *SSEConnection) Close()

Close - Close the current connection

func (*SSEConnection) Init

func (connection *SSEConnection) Init()

Init - Initialize connection channels

func (*SSEConnection) Send

func (connection *SSEConnection) Send(payload []byte)

Send - Enqueue message into channel

func (*SSEConnection) SendText

func (connection *SSEConnection) SendText(payload []byte)

SendText - Enqueue message into channel

func (*SSEConnection) SetOnClose

func (connection *SSEConnection) SetOnClose(cb func())

SetOnClose - Callback for when connection closes

func (*SSEConnection) SetOnMessage

func (connection *SSEConnection) SetOnMessage(cb func([]byte))

SetOnMessage - In this type of connection the callback won't do anything

type WebSocketConnection

type WebSocketConnection struct {
	// contains filtered or unexported fields
}

WebSocketConnection - Implementation of the Connection interface for WebSocket clients

func (*WebSocketConnection) Close

func (connection *WebSocketConnection) Close()

Close - Close the current connection

func (*WebSocketConnection) Init

func (connection *WebSocketConnection) Init(ws *websocket.Conn)

Init - Initialize connection and start reading and writing messages

func (*WebSocketConnection) IsConnected

func (connection *WebSocketConnection) IsConnected() bool

IsConnected - If connection is still alive

func (*WebSocketConnection) Send

func (connection *WebSocketConnection) Send(data []byte)

Send - Send the data to the client

func (*WebSocketConnection) SendText

func (connection *WebSocketConnection) SendText(data []byte)

SendText - Send the data to the client

func (*WebSocketConnection) SetOnClose

func (connection *WebSocketConnection) SetOnClose(cb func())

SetOnClose - Set on closed connection handler

func (*WebSocketConnection) SetOnHeartBeat

func (connection *WebSocketConnection) SetOnHeartBeat(cb func())

func (*WebSocketConnection) SetOnMessage

func (connection *WebSocketConnection) SetOnMessage(cb func([]byte))

SetOnMessage - Set user sent message callback

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL