| | |
| | | //import com.nq.service.impl.MandatoryLiquidationService; |
| | | //import com.nq.utils.ApplicationContextRegisterUtil; |
| | | //import com.nq.utils.PropertiesUtil; |
| | | //import com.nq.utils.redis.RedisKeyUtil; |
| | | //import com.nq.ws.client.IO; |
| | | //import com.nq.ws.client.Socket; |
| | | //import io.socket.emitter.Emitter; |
| | |
| | | //import java.util.Date; |
| | | //import java.util.List; |
| | | //import java.util.Map; |
| | | /** |
| | | * soket-io |
| | | */ |
| | | // |
| | | ///** |
| | | // * soket-io |
| | | // */ |
| | | //@Slf4j |
| | | //@Configuration |
| | | //public class WsClientConfig { |
| | |
| | | // private static final String ROOM_ID = "14"; |
| | | // private static Socket socket; |
| | | // |
| | | // private static HttpClient httpClient = HttpClients.createDefault(); // 单例化 HttpClient |
| | | // |
| | | // |
| | | // private static HttpPost httpPost; |
| | | // static { |
| | | // httpPost = new HttpPost("http://127.0.0.1:8001/api/sendNotification"); // 初始化 HttpPost |
| | | // } |
| | | // @Bean |
| | | // public void websocketRunClientMap() { |
| | | // connectToServer(); |
| | |
| | | // socket.on("marketData", new Emitter.Listener() { |
| | | // @Override |
| | | // public void call(Object... args) { |
| | | // Map<String, Object> map = jsonToMap(args[0].toString()); |
| | | // if(map.get("pid").equals("00000001")){ |
| | | // System.out.println("接收时间:" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + " " + args[0].toString()); |
| | | // } |
| | | // try { |
| | | // ApplicationContext act = ApplicationContextRegisterUtil.getApplicationContext(); |
| | | // MandatoryLiquidationService liquidationService = (MandatoryLiquidationService) act.getBean(IMandatoryLiquidationService.class); |
| | | // StockRealTimeBean stockDetailBean = new Gson().fromJson(args[0].toString(), StockRealTimeBean.class); |
| | | // liquidationService.RealTimeDataProcess(EStockType.IN,stockDetailBean); |
| | | // }catch (Exception e){ |
| | | // log.error("socket数据存入缓存错误:", e.getMessage()); |
| | | // } |
| | | // send(args[0].toString()); |
| | | // StockRealTimeBean stockDetailBean = new Gson().fromJson(args[0].toString(), StockRealTimeBean.class); |
| | | // RedisKeyUtil.setCacheRealTimeStock(EStockType.IN,stockDetailBean); |
| | | // } |
| | | // }); |
| | | // |
| | |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // private static void send(String message) { |
| | | // try { |
| | | // // 准备 form-data 参数 |
| | | // List<BasicNameValuePair> params = new ArrayList<>(); |
| | | // params.add(new BasicNameValuePair("message", message)); |
| | | // |
| | | // // 设置编码格式为 UTF-8 |
| | | // UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, StandardCharsets.UTF_8); |
| | | // httpPost.setEntity(entity); // 设置 HttpPost 对象的参数 |
| | | // |
| | | // // 发送请求 |
| | | // HttpResponse response = httpClient.execute(httpPost); |
| | | // |
| | | // // 处理响应 |
| | | // int statusCode = response.getStatusLine().getStatusCode(); |
| | | // } catch (IOException e) { |
| | | // log.error("Http 请求错误", e); |
| | | // } |
| | | // } |
| | | //} |