MCPcopy Index your code
hub / github.com/ccxt/ccxt / client

Method client

java/lib/src/main/java/io/github/ccxt/Exchange.java:1636–1682  ·  view source on GitHub ↗
(Object url2)

Source from the content-addressed store, hash-verified

1634 // ─── WebSocket Bridge (matches C# Exchange.WsBridge.cs) ───
1635
1636 @SuppressWarnings("unchecked")
1637 public Client client(Object url2) {
1638 String url = url2.toString();
1639 return ((java.util.concurrent.ConcurrentHashMap<String, Client>) this.clients)
1640 .computeIfAbsent(url, u -> {
1641 Object ws = this.safeValue(this.options, "ws", new java.util.HashMap<String, Object>());
1642 Object wsOptions = this.safeValue(ws, "options", new java.util.HashMap<String, Object>());
1643 long keepAlive = 30000;
1644 Object keepAliveObj = this.safeValue(wsOptions, "keepAlive", null);
1645 if (keepAliveObj instanceof Number n) keepAlive = n.longValue();
1646 boolean decompressBin = true;
1647 Object decompressObj = this.safeValue(this.options, "decompressBinary", null);
1648 if (decompressObj instanceof Boolean b) decompressBin = b;
1649
1650 var result = this.checkWsProxySettings();
1651 String proxy = null;
1652 if (result instanceof java.util.List<?> proxies) {
1653 for (Object p : proxies) {
1654 if (p != null) { proxy = p.toString(); break; }
1655 }
1656 }
1657
1658 Client created = new Client(u, proxy,
1659 (client, msg) -> this.handleMessage((Client) client, msg),
1660 (client) -> this.ping((Client) client),
1661 (client, err) -> this.onClose((Client) client, err),
1662 (client, err) -> this.onError((Client) client, err),
1663 this.verbose, keepAlive, decompressBin,
1664 this.validateServerSsl);
1665
1666 // Forward options.ws.options.headers to the upgrade request — required
1667 // by exchanges that gate on User-Agent (weex) or send custom headers.
1668 Object headers = this.safeValue(wsOptions, "headers", null);
1669 if (headers instanceof java.util.Map<?, ?> m) {
1670 java.util.Map<String, String> hh = new java.util.HashMap<>();
1671 for (java.util.Map.Entry<?, ?> e : m.entrySet()) {
1672 if (e.getKey() == null || e.getValue() == null) continue;
1673 hh.put(e.getKey().toString(), e.getValue().toString());
1674 }
1675 if (!hh.isEmpty()) {
1676 created.handshakeHeaders = hh;
1677 }
1678 }
1679
1680 return created;
1681 });
1682 }
1683
1684 public CompletableFuture<Object> watch(Object url, Object messageHash2, Object message, Object subscribeHash2, Object subscription) {
1685 String messageHash = messageHash2.toString();

Callers 15

watchMethod · 0.95
watchMultipleMethod · 0.95
keepAliveListenKeyMethod · 0.45
watchBalanceMethod · 0.45
watchPositionsMethod · 0.45
watchOrdersMethod · 0.45
watchMyTradesMethod · 0.45
authenticateMethod · 0.45
watchPrivateMethod · 0.45
handleUnsubscriptionsMethod · 0.45
authenticateMethod · 0.45
watchPositionsMethod · 0.45

Calls 9

safeValueMethod · 0.95
checkWsProxySettingsMethod · 0.95
handleMessageMethod · 0.95
pingMethod · 0.95
onCloseMethod · 0.95
onErrorMethod · 0.95
isEmptyMethod · 0.80
toStringMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected