All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.binance.connector.client.impl.websocketapi.WebSocketApiUserDataStream Maven / Gradle / Ivy

There is a newer version: 3.2.0
Show newest version
package com.binance.connector.client.impl.websocketapi;

import org.json.JSONObject;

import com.binance.connector.client.utils.JSONParser;
import com.binance.connector.client.utils.ParameterChecker;
import com.binance.connector.client.utils.websocketapi.WebSocketApiRequestHandler;

/**
 * 

User Data Stream Requests

* All requests under the * User Data Stream requests * section of the WebSocket API documentation will be implemented in this class. *
* Response will be returned as callback. */ public class WebSocketApiUserDataStream { private WebSocketApiRequestHandler handler; public WebSocketApiUserDataStream(WebSocketApiRequestHandler handler) { this.handler = handler; } /** * Start a new user data stream.
* * The response will output a listen key that can be subscribed through on the WebSocket stream afterwards.
* * Note: the stream will close in 60 minutes unless userDataStream.ping requests are sent regularly.
* * @param parameters JSONObject composed by key-value pairs: *

* requestId -- optional/String or int
* * @see * https://binance-docs.github.io/apidocs/websocket_api/en/#start-user-data-stream-user_stream */ public void userDataStreamStart(JSONObject parameters) { this.handler.apiRequest("userDataStream.start", parameters); } /** * Ping a user data stream to keep it alive.
* * User data streams close automatically after 60 minutes, even if you're listening to them on WebSocket Streams.
* In order to keep the stream open, you have to regularly send pings using the userDataStream.ping request.
* It is recommended to send a ping once every 30 minutes.
* * Note: the stream will close in 60 minutes unless userDataStream.ping requests are sent regularly.
* * @param listenKey -- required/String
* @param parameters JSONObject composed by key-value pairs: *

* requestId -- optional/String or int
* * @see * https://binance-docs.github.io/apidocs/websocket_api/en/#ping-user-data-stream-user_stream */ public void userDataStreamPing(String listenKey, JSONObject parameters) { ParameterChecker.checkParameterType(listenKey, String.class, "listenKey"); parameters = JSONParser.addKeyValue(parameters, "listenKey", listenKey); this.handler.apiRequest("userDataStream.ping", parameters); } /** * Explicitly stop and close the user data stream.
* * @param listenKey -- required/String
* @param parameters JSONObject composed by key-value pairs: *

* requestId -- optional/String or int
* * @see * https://binance-docs.github.io/apidocs/websocket_api/en/#stop-user-data-stream-user_stream */ public void userDataStreamStop(String listenKey, JSONObject parameters) { ParameterChecker.checkParameterType(listenKey, String.class, "listenKey"); parameters = JSONParser.addKeyValue(parameters, "listenKey", listenKey); this.handler.apiRequest("userDataStream.stop", parameters); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy