client

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New() *Client

New returns pointer to Client instance

func (*Client) AddSub

func (c *Client) AddSub(sub event.Subscribe)

AddSub adds new subscription to the list

func (*Client) Close

func (c *Client) Close() error

Close closes the socket connection

func (*Client) GetAllSubs

func (c *Client) GetAllSubs() (res []event.Subscribe)

GetAllSubs returns all subscriptions

func (*Client) Private

func (c *Client) Private(key, sec, url string, dms int) (*Client, error)

Private creates and returns client to interact with private channels

func (*Client) Public

func (c *Client) Public(url string) (*Client, error)

Public creates and returns client to interact with public channels

func (*Client) Read

func (c *Client) Read(ch chan<- msg.Msg)

Read starts consuming data stream

func (*Client) RemoveSub

func (c *Client) RemoveSub(sub event.Subscribe)

RemoveSub removes new subscription to the list

func (*Client) Send

func (c *Client) Send(pld interface{}) error

Send takes payload in form of interface and sends it to api

func (*Client) SubAdded

func (c *Client) SubAdded(sub event.Subscribe) (isAdded bool)

SubAdded checks if given subscription is already added. Used to avoid duplicate subscriptions per client

func (*Client) SubsLimitReached

func (c *Client) SubsLimitReached() bool

SubsLimitReached returns true if number of subs > subsLimit

func (*Client) Subscribe

func (c *Client) Subscribe(sub event.Subscribe) error

Subscribe takes subscription payload as per docs and subscribes client to it. We keep track of subscriptions so that when client failes, we can resubscribe.

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(chanID int64) error

Unsubscribe takes channel id and unsubscribes client from it.

func (*Client) WithID

func (c *Client) WithID(ID int) *Client

WithID assigns clinet ID

func (*Client) WithSubsLimit

func (c *Client) WithSubsLimit(limit int) *Client

WithSubsLimit sets limit of subscriptions on the instance

Jump to

Keyboard shortcuts

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