| | |
| | | log.error("WebSocket登录失败, code: {}, msg: {}", code, response.getString("msg")); |
| | | } |
| | | } else if ("subscribe".equals(event)) { |
| | | log.info("订阅成功: {}", response.getJSONObject("arg")); |
| | | subscribeEvent(response); |
| | | } else if ("error".equals(event)) { |
| | | log.error("订阅错误: code={}, msg={}", |
| | | response.getString("code"), response.getString("msg")); |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("处理WebSocket消息失败: {}", message, e); |
| | | } |
| | | } |
| | | |
| | | private void subscribeEvent(JSONObject response) { |
| | | String channel = response.getString("channel"); |
| | | if (OrderInfoWs.ORDERINFOWS_CHANNEL.equals(channel)) { |
| | | OrderInfoWs.initEvent(response); |
| | | } |
| | | if (AccountWs.ACCOUNTWS_CHANNEL.equals(channel)) { |
| | | AccountWs.initEvent(response); |
| | | } |
| | | if (PositionsWs.POSITIONSWS_CHANNEL.equals(channel)) { |
| | | PositionsWs.initEvent(response); |
| | | } |
| | | } |
| | | |
| | |
| | | OrderInfoWs.handleEvent(response, redisUtils); |
| | | }else if (AccountWs.ACCOUNTWS_CHANNEL.equals(channel)) { |
| | | AccountWs.handleEvent(response); |
| | | String side = caoZuoService.caoZuo(); |
| | | TradeOrderWs.orderEvent(webSocketClient, side); |
| | | } else if (PositionsWs.POSITIONSWS_CHANNEL.equals(channel)) { |
| | | PositionsWs.handleEvent(response); |
| | | } else if (BalanceAndPositionWs.CHANNEL_NAME.equals(channel)) { |
| | | BalanceAndPositionWs.handleEvent(response); |
| | | } |
| | | String side = caoZuoService.caoZuo(); |
| | | TradeOrderWs.orderEvent(webSocketClient, side); |
| | | } |
| | | |
| | | /** |