Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateWsSignature(apiSecret, data string) string
- type ChannelType
- type Client
- type CommonResponse
- type Environment
- type PingMsg
- type SoppingOptionsResponse
- type SubChannel
- type SuccessResponse
- type WSPongPrivateLinearInverseResponse
- type WSPongPrivateResponse
- type WSPongPrivateSpotResponse
- type WSPongPublicLinearInverseResponse
- type WSPongPublicResponse
- type WSPongPublicSpotResponse
Constants ¶
const ( DefaultScheme = "wss" PingInterval = 20 * time.Second PingOperation = "ping" AuthOperation = "auth" ReconnectionRetries = 3 ReconnectionDelay = 10 * time.Second Public = "public" Private = "private" )
const ( // WSMessageText represents the message type for text in WebSocket communications. WSMessageText = websocket.TextMessage )
Variables ¶
var (
DefaultReqID = randomString(8)
)
Functions ¶
func GenerateWsSignature ¶
GenerateWsSignature generates a signature for the WebSocket API.
Types ¶
type ChannelType ¶
type ChannelType string
ChannelType defines the types of channels (public/private) that the WebSocket client can connect to.
type Client ¶ added in v0.1.6
type Client struct { IsTestNet bool ApiKey string ApiSecret string Channel ChannelType Path string Connected chan struct{} OnConnected func() OnConnectionError func(err error) Category string MaxActiveTime string // contains filtered or unexported fields }
Client is the main WebSocket client struct, managing the connection and its state.
func NewPrivateClient ¶ added in v0.1.26
func NewPrivateClient(apiKey, apiSecret string, isTestNet bool, maxActiveTime string, category string) (*Client, error)
NewPrivateClient initializes a new private WSClient instance.
func NewPublicClient ¶ added in v0.1.26
NewPublicClient initializes a new public WSClient instance.
func (*Client) Authenticate ¶ added in v0.1.6
Authenticate sends an authentication request to the WebSocket server.
func (*Client) Close ¶ added in v0.1.6
func (c *Client) Close()
Close gracefully closes the WebSocket connection.
func (*Client) Connect ¶ added in v0.1.6
Connect establishes a WebSocket connection to the server based on the configuration.
func (*Client) GetConnection ¶ added in v0.1.52
type CommonResponse ¶
type CommonResponse struct { Op string `json:"op"` // Op is the operation of the request ConnId string `json:"conn_id"` // ConnId is the connection ID of the request }
CommonResponse encapsulates fields that are common across various WebSocket responses.
type Environment ¶
type Environment string
Environment denotes the environment in which the Bybit API operates (e.g., "production", "development").
type SoppingOptionsResponse ¶
SoppingOptionsResponse describes the sopping options with associated arguments and operations.
type SubChannel ¶
type SubChannel string
SubChannel represents a sub-channel for Bybit API's WebSocket communications.
type SuccessResponse ¶
type SuccessResponse struct { CommonResponse Success bool `json:"success"` // Success indicates the success status of the request RetMsg string `json:"ret_msg"` // RetMsg provides details on the return message of the request }
SuccessResponse represents the response structure for a successful WebSocket request. It provides details about the operation, connection ID, success status, and return message.
type WSPongPrivateLinearInverseResponse ¶
type WSPongPrivateLinearInverseResponse WSPongPrivateResponse
WSPongPrivateLinearInverseResponse represents a specific private pong response for linear inverse operations.
type WSPongPrivateResponse ¶
type WSPongPrivateResponse struct { CommonResponse ReqId string `json:"req_id"` Args []string `json:"args"` }
WSPongPrivateResponse contains fields common to private pong responses. It also provides a unique request ID and arguments associated with the response.
type WSPongPrivateSpotResponse ¶
type WSPongPrivateSpotResponse WSPongPrivateResponse
WSPongPrivateSpotResponse represents a specific private pong response for the spot.
type WSPongPublicLinearInverseResponse ¶
type WSPongPublicLinearInverseResponse struct { WSPongPublicResponse ReqId string `json:"req_id"` }
WSPongPublicLinearInverseResponse represents a specific public pong response for linear inverse operations and also contains a unique request ID.
type WSPongPublicResponse ¶
type WSPongPublicResponse struct {
SuccessResponse
}
WSPongPublicResponse contains fields common to public pong responses.
type WSPongPublicSpotResponse ¶
type WSPongPublicSpotResponse WSPongPublicResponse
WSPongPublicSpotResponse represents a specific public pong response for the spot.