websocket

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMarketChannelCreator

func NewMarketChannelCreator(fetcher SnapshotFetcher) func(channelID string) IChannel

func RegisterChannelCreator

func RegisterChannelCreator(prefix string, fn func(channelID string) IChannel)

Types

type Channel

type Channel struct {
	ID      string
	Clients map[string]*Client

	Subscribe   chan *Client
	Unsubscribe chan string
	Messages    chan *common.WebSocketMessage
}

Channel is a basic type implemented IChannel

func (*Channel) AddMessage

func (c *Channel) AddMessage(msg *common.WebSocketMessage)

func (*Channel) AddSubscriber

func (c *Channel) AddSubscriber(client *Client)

func (*Channel) GetID

func (c *Channel) GetID() string

func (*Channel) MessagesChan

func (c *Channel) MessagesChan() chan *common.WebSocketMessage

func (*Channel) RemoveSubscriber

func (c *Channel) RemoveSubscriber(ID string)

func (*Channel) SubScribeChan

func (c *Channel) SubScribeChan() chan *Client

func (*Channel) UnsubscribeChan

func (c *Channel) UnsubscribeChan() chan string

type Client

type Client struct {
	ID       string
	Conn     clientConn
	Channels map[string]*Channel
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

func (*Client) Send

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

type ClientRequest

type ClientRequest struct {
	Type     string
	Channels []string
}

type DefaultHttpSnapshotFetcher

type DefaultHttpSnapshotFetcher struct {
	ApiUrl string
}

func (*DefaultHttpSnapshotFetcher) GetV2

func (f *DefaultHttpSnapshotFetcher) GetV2(marketID string) *common.SnapshotV2

type IChannel

type IChannel interface {
	GetID() string

	// Thread safe calls
	AddSubscriber(*Client)
	RemoveSubscriber(string)
	AddMessage(message *common.WebSocketMessage)

	UnsubscribeChan() chan string
	SubScribeChan() chan *Client
	MessagesChan() chan *common.WebSocketMessage
	// contains filtered or unexported methods
}

type OnMessageResult

type OnMessageResult struct {
	Price  decimal.Decimal
	Side   string
	Amount decimal.Decimal
}

type Orderbook

type Orderbook struct {
	Sequence uint64
	*common.Orderbook
	// contains filtered or unexported fields
}

type SnapshotFetcher

type SnapshotFetcher interface {
	GetV2(marketID string) *common.SnapshotV2
}

type WSServer

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

func NewWSServer

func NewWSServer(addr string, sourceQueue common.IQueue) *WSServer

func (*WSServer) Start

func (s *WSServer) Start(ctx context.Context)

Jump to

Keyboard shortcuts

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