| | |
| | | package com.iplatform.tcp; |
| | | |
| | | import com.iplatform.tcp.util.ws.WebDataResponse; |
| | | import com.walker.infrastructure.utils.JsonUtils; |
| | | import com.walker.infrastructure.utils.NumberGenerator; |
| | | import org.junit.Test; |
| | | |
| | | public class WebsocketDemo { |
| | | |
| | | @Test |
| | | public void sendDataFormat(){ |
| | | WebDataResponse msg = new WebDataResponse(); |
| | | msg.setMessageId(NumberGenerator.getLongSequenceId()); |
| | | msg.setName("shikeying"); // 指定用户发送,该id与浏览器端注册的id保持一致。 |
| | | msg.setData("你好,这是推送给浏览器的内容,一般是JSON格式。"); |
| | | try { |
| | | System.out.println(JsonUtils.objectToJsonString(msg)); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | // @Test |
| | | // public void sendDataFormat(){ |
| | | // WebDataResponse msg = new WebDataResponse(); |
| | | // msg.setMessageId(NumberGenerator.getLongSequenceId()); |
| | | // msg.setName("shikeying"); // 指定用户发送,该id与浏览器端注册的id保持一致。 |
| | | // msg.setData("你好,这是推送给浏览器的内容,一般是JSON格式。"); |
| | | // try { |
| | | // System.out.println(JsonUtils.objectToJsonString(msg)); |
| | | // } catch (Exception e) { |
| | | // throw new RuntimeException(e); |
| | | // } |
| | | // } |
| | | } |