websocket

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 19 Imported by: 1

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
}

Client is a WebSocket message transport client for API v3.

func NewClient

func NewClient(server, network string) (*Client, error)

NewClient returns a new WebSocket API client for the given server.

func (*Client) Close

func (c *Client) Close() error

Close closes the client.

func (*Client) ConsensusStatus

func (c *Client) ConsensusStatus(ctx context.Context, opts api.ConsensusStatusOptions) (*api.ConsensusStatus, error)

ConsensusStatus implements api.ConsensusService.ConsensusStatus.

func (*Client) Done

func (c *Client) Done() <-chan struct{}

Done returns a channel that will be closed once the client is closed.

func (*Client) Faucet

func (c *Client) Faucet(ctx context.Context, account *url.URL, opts api.FaucetOptions) (*api.Submission, error)

Faucet implements api.Faucet.Faucet.

func (*Client) FindService

func (c *Client) FindService(ctx context.Context, opts api.FindServiceOptions) ([]*api.FindServiceResult, error)

FindService implements api.NodeService.FindService.

func (*Client) Metrics

func (c *Client) Metrics(ctx context.Context, opts api.MetricsOptions) (*api.Metrics, error)

Metrics implements api.MetricsService.Metrics.

func (*Client) NetworkStatus

func (c *Client) NetworkStatus(ctx context.Context, opts api.NetworkStatusOptions) (*api.NetworkStatus, error)

NetworkStatus implements api.NetworkService.NetworkStatus.

func (*Client) NodeInfo

func (c *Client) NodeInfo(ctx context.Context, opts api.NodeInfoOptions) (*api.NodeInfo, error)

NodeInfo implements api.NodeService.NodeInfo.

func (*Client) Query

func (c *Client) Query(ctx context.Context, scope *url.URL, query api.Query) (api.Record, error)

Query implements api.Querier.Query.

func (*Client) Submit

func (c *Client) Submit(ctx context.Context, envelope *messaging.Envelope, opts api.SubmitOptions) ([]*api.Submission, error)

Submit implements api.Submitter.Submit.

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, opts api.SubscribeOptions) (<-chan api.Event, error)

Subscribe implements api.EventService.Subscribe.

func (*Client) Validate

func (c *Client) Validate(ctx context.Context, envelope *messaging.Envelope, opts api.ValidateOptions) ([]*api.Submission, error)

Validate implements api.Validator.Validate.

type Handler

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

Handler handles WebSocket connections.

func NewHandler

func NewHandler(services ...message.Service) (*Handler, error)

NewHandler constructs a new Handler with the given list of services. NewHandler only returns an error if more than one service attempts to register a method for the same request type.

func (*Handler) FallbackTo

func (s *Handler) FallbackTo(fallback http.Handler) http.Handler

FallbackTo returns an http.Handler that falls back to the given handler if the request is not a websocket request. This allows the WebSocket services to coexist with traditional HTTP services.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

type Message

type Message struct {
	ID      uint64          `json:"id,omitempty" form:"id" query:"id" validate:"required"`
	Status  StreamStatus    `json:"status,omitempty" form:"status" query:"status" validate:"required"`
	Message message.Message `json:"message,omitempty" form:"message" query:"message"`
	// contains filtered or unexported fields
}

func (*Message) Copy

func (v *Message) Copy() *Message

func (*Message) CopyAsInterface

func (v *Message) CopyAsInterface() interface{}

func (*Message) Equal

func (v *Message) Equal(u *Message) bool

func (*Message) IsValid

func (v *Message) IsValid() error

func (*Message) MarshalBinary

func (v *Message) MarshalBinary() ([]byte, error)

func (*Message) MarshalJSON

func (v *Message) MarshalJSON() ([]byte, error)

func (*Message) UnmarshalBinary

func (v *Message) UnmarshalBinary(data []byte) error

func (*Message) UnmarshalBinaryFrom

func (v *Message) UnmarshalBinaryFrom(rd io.Reader) error

func (*Message) UnmarshalJSON

func (v *Message) UnmarshalJSON(data []byte) error

type StreamStatus

type StreamStatus int

StreamStatus indicates the status of a sub-stream.

const StreamStatusClosed StreamStatus = 2

StreamStatusClosed .

const StreamStatusOpen StreamStatus = 1

StreamStatusOpen .

func StreamStatusByName

func StreamStatusByName(name string) (StreamStatus, bool)

StreamStatusByName returns the named Stream Status.

func (StreamStatus) GetEnumValue

func (v StreamStatus) GetEnumValue() uint64

GetEnumValue returns the value of the Stream Status

func (StreamStatus) MarshalJSON

func (v StreamStatus) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Stream Status to JSON as a string.

func (*StreamStatus) SetEnumValue

func (v *StreamStatus) SetEnumValue(id uint64) bool

SetEnumValue sets the value. SetEnumValue returns false if the value is invalid.

func (StreamStatus) String

func (v StreamStatus) String() string

String returns the name of the Stream Status.

func (*StreamStatus) UnmarshalJSON

func (v *StreamStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the Stream Status from JSON as a string.

Jump to

Keyboard shortcuts

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