socketyapi

package
v0.0.0-...-78446d3 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: MIT Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// InternalAPIs service pool of sockets this message applies to
	InternalAPIs service = iota
	// Commentron service pool of sockets this message applies to
	Commentron
	// BlockChain service pool of sockets for monitoring blockchain stream
	BlockChain
)
View Source
const (
	// Viewers monitors viewers messages that show connection count
	Viewers = Monitor("viewers")
	// Deltas monitors the new comments coming in.
	Deltas = Monitor("delta")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*http.Client

	WebSockets []WebSocketClient
	// contains filtered or unexported fields
}

Client sockety client for making calls to sockety api

func NewClient

func NewClient(url, token string) *Client

NewClient creates a new sockety client

func (*Client) Listen

func (c *Client) Listen(params WebSocketClientParams) error

Listen connects and listens for websocket messages.

func (Client) SendNotification

func (c Client) SendNotification(args SendNotificationArgs) (*SendNotificationResponse, error)

SendNotification sends a notification to a service's connected socket

type Monitor

type Monitor string

Monitor describes the type of messages of a service that you would like to listen for.

type SendNotificationArgs

type SendNotificationArgs struct {
	Service     service
	Type        string
	IDs         []string
	Category    *string
	SubCategory *string
	Data        map[string]interface{}
}

SendNotificationArgs Arguments for sending funds via dispendium

type SendNotificationResponse

type SendNotificationResponse struct {
	*http.Response
	Success bool                    `json:"success"`
	Error   *string                 `json:"error"`
	Data    *SendNotificationResult `json:"data,omitempty"`
	Trace   []string                `json:"_trace,omitempty"`
}

SendNotificationResponse response from the api call. It includes the http response plus the result

type SendNotificationResult

type SendNotificationResult struct {
	LBCAmount     float64 `json:"lbc_amount"`
	SatoshiAmount uint64  `json:"satoshi_amount"`
	TxHash        string  `json:"tx_id"`
}

SendNotificationResult result from the api call to send funds

type ViewersMsg

type ViewersMsg struct {
	Connected int `json:"connected"`
}

ViewersMsg Message showing how many users are connected to sockety for the specific ID.

func ToViewersMsg

func ToViewersMsg(n *push.Notification) (ViewersMsg, error)

ToViewersMsg extracts ViewersMsg from Notification

type WebSocketClient

type WebSocketClient interface {
	Connect() error
	OnMessage([]byte) error
	OnClose() error
	OnOpen() error
	OnError(error)
	SendMessage([]byte) error
}

WebSocketClient connection client

type WebSocketClientParams

type WebSocketClientParams struct {
	Service     service
	ID          string
	OnMessageFn func(notification *push.Notification)
	OnCloseFn   func()
	OnOpenFn    func()
	OnErrorFn   func(err error)
	Monitors    []Monitor
}

WebSocketClientParams parameters to listen to a websocket subscription

Jump to

Keyboard shortcuts

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