Documentation ¶
Index ¶
- func DefaultClientEncodingMiddleware(client *Client, message []byte) ([]byte, error)
- func ErrorResponse(ctx Context, err string)
- func NormalResponse(ctx Context, data map[string]interface{})
- func Response(client string, action string, data map[string]interface{}, ...)
- func StatusResponse(ctx Context, status string)
- func SuccessResponse(ctx Context)
- type Client
- type Config
- type ConnectionTokenClaims
- type Context
- type Instance
- func (instance *Instance) AddClient(client Client) *Client
- func (instance *Instance) CheckToken(token string, local *pipes.LocalNode) (*ConnectionTokenClaims, bool)
- func (instance *Instance) ExistsConnection(id string, session string) bool
- func (instance *Instance) Get(id string, session string) (*Client, bool)
- func (instance *Instance) GetConnections(id string) int
- func (instance *Instance) GetSessions(id string) []string
- func (instance *Instance) Handle(ctx Context) bool
- func (instance *Instance) RegisterHandler(action string, handler func(Context))
- func (instance *Instance) Remove(id string, session string)
- func (instance *Instance) ReportClientError(client *Client, context string, err error)
- func (instance *Instance) ReportGeneralError(context string, err error)
- func (instance *Instance) Send(id string, msg []byte)
- func (instance *Instance) SendEvent(c *Client, event pipes.Event) error
- func (instance *Instance) SendMessage(conn *websocket.Conn, client *Client, msg []byte) error
- func (instance *Instance) SendSession(id string, session string, msg []byte) bool
- func (instance *Instance) SetupConnectionsCache(expected int64)
- func (instance *Instance) UpdateClient(client *Client)
- type Message
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultClientEncodingMiddleware ¶
Default pipes-fiber encoding middleware (using JSON)
func ErrorResponse ¶
func NormalResponse ¶
func StatusResponse ¶
func SuccessResponse ¶
func SuccessResponse(ctx Context)
Types ¶
type Client ¶
type Config ¶
type Config struct { ExpectedConnections int64 SessionDuration time.Duration // How long a session should stay alive Secret []byte // JWT secret (for authorization) // Node handlers NodeDisconnectHandler func(node pipes.Node) // Client handlers ClientDisconnectHandler func(client *Client) TokenValidateHandler func(claims *ConnectionTokenClaims, attachments string) bool // Called before the websocket connection is accepted, returns if the client should be disconnected (true = disconnect) ClientConnectHandler func(client *Client, attachments string) bool // Called after websocket connection is established, returns if the client should be disconnected (true = disconnect) ClientEnterNetworkHandler func(client *Client, attachments string) bool // Called after pipes adapter is registered, returns if the client should be disconnected (true = disconnect) // Codec middleware ClientEncodingMiddleware func(client *Client, instance *Instance, message []byte) ([]byte, error) DecodingMiddleware func(client *Client, instance *Instance, message []byte) (Message, error) // Error handler ErrorHandler func(err error) }
! If the functions aren't implemented pipesfiber will panic
type ConnectionTokenClaims ¶
type ConnectionTokenClaims struct { Account string `json:"acc"` // Account id of the connecting client ExpiredUnixSec int64 `json:"e_u"` // Expiration time in unix seconds Session string `json:"ses"` // Session id of the connecting client Node string `json:"node"` // Node id of the node the client is connecting to jwt.RegisteredClaims }
Connection token struct
type Context ¶
type Context struct { Client *Client `json:"client"` Action string `json:"action"` // The action to perform Data map[string]interface{} `json:"data"` Node *pipes.LocalNode `json:"-"` }
func (*Context) ValidateForm ¶
Returns true if one of the fields is not set
type Instance ¶
type Instance struct { Config Config // contains filtered or unexported fields }
func (*Instance) CheckToken ¶
func (instance *Instance) CheckToken(token string, local *pipes.LocalNode) (*ConnectionTokenClaims, bool)
Check the JWT token
func (*Instance) ExistsConnection ¶
func (*Instance) GetConnections ¶
func (*Instance) GetSessions ¶
func (*Instance) RegisterHandler ¶
func (*Instance) ReportClientError ¶
func (*Instance) ReportGeneralError ¶
func (*Instance) SendMessage ¶
func (*Instance) SendSession ¶
func (*Instance) SetupConnectionsCache ¶
func (*Instance) UpdateClient ¶
Click to show internal directories.
Click to hide internal directories.