| | |
| | | @OnOpen |
| | | public void onOpen(Session session) { |
| | | onlineCount.incrementAndGet(); // 在线数加1 |
| | | log.info("有新连接加入:{},当前在线人数为:{}", session.getId(), onlineCount.get()); |
| | | // log.info("有新连接加入:{},当前在线人数为:{}", session.getId(), onlineCount.get()); |
| | | } |
| | | |
| | | /** |
| | |
| | | map.remove(session.getId()); |
| | | } |
| | | } |
| | | log.info("有一连接关闭:{},当前在线人数为:{}", session.getId(), onlineCount.get()); |
| | | //log.info("有一连接关闭:{},当前在线人数为:{}", session.getId(), onlineCount.get()); |
| | | } |
| | | |
| | | /** |
| | |
| | | // 发送订阅消息 |
| | | String nekk = factory.getTrader(SymbolsConstats.ROC).sendTradePlateMessage(); |
| | | SubResultModel subResultModel = new SubResultModel(); |
| | | subResultModel.setId("rocusdt"); |
| | | subResultModel.setId("bzzusdt"); |
| | | subResultModel.setSubbed(sub); |
| | | synchronized (session) { |
| | | try { |
| | |
| | | String key = "KINE_{}_{}"; |
| | | // 币币k线数据 |
| | | //key = StrUtil.format(key, symbol, period); |
| | | key = StrUtil.format(key, "ROC/USDT", period); |
| | | key = StrUtil.format(key, "BZZ/USDT", period); |
| | | RedisUtils bean = SpringContextHolder.getBean(RedisUtils.class); |
| | | Object o = bean.get(key); |
| | | List<CandlestickModel> candlestickModels = new ArrayList<>(); |
| | |
| | | result.setRep(sub); |
| | | if (o != null) { |
| | | List<Candlestick> list = (List<Candlestick>) o; |
| | | |
| | | if(list!=null && list.size()>300){ |
| | | int size = list.size(); |
| | | list = list.subList(size-300,size); |
| | | } |
| | | CandlestickModel model = null; |
| | | for (Candlestick candlestick : list) { |
| | | CandlestickModel model = new CandlestickModel(); |
| | | model = new CandlestickModel(); |
| | | model.setAmount(candlestick.getAmount()); |
| | | model.setClose(candlestick.getClose()); |
| | | model.setCount(candlestick.getCount()); |
| | |
| | | |
| | | @OnError |
| | | public void onError(Session session, Throwable error) { |
| | | log.error("发生错误"); |
| | | error.printStackTrace(); |
| | | // log.error("发生错误"); |
| | | //error.printStackTrace(); |
| | | } |
| | | |
| | | /** |