1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  | /** 
 |   * Copyright (c) 2016-2020 人人开源 All rights reserved. 
 |   * <p> 
 |   * https://www.renren.io 
 |   * <p> 
 |   * 版权所有,侵权必究! 
 |   */ 
 |    
 |  package com.zt.modules.message.websocket.data; 
 |    
 |  import lombok.Data; 
 |    
 |  /** 
 |   * 响应客户端数据 
 |   * 
 |   * @author Mark sunlightcs@gmail.com 
 |   */ 
 |  @Data 
 |  public class MessageData<T> { 
 |      /** 
 |       * 编码  0:文本消息  1:对象消息 
 |       */ 
 |      private int type = 0; 
 |      /** 
 |       * 文本消息 
 |       */ 
 |      private String msg; 
 |      /** 
 |       * 对象消息 
 |       */ 
 |      private T data; 
 |    
 |      public MessageData<T> data(T data) { 
 |          this.setData(data); 
 |          this.type = 1; 
 |          return this; 
 |      } 
 |    
 |      public MessageData<T> msg(String msg) { 
 |          this.msg = msg; 
 |          return this; 
 |      } 
 |  } 
 |  
  |