Command.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. package org.jim.common.packets;
  2. import org.jim.common.utils.DynamicEnumUtil;
  3. public enum Command{
  4. /**
  5. * <code>COMMAND_UNKNOW = 0;</code>
  6. */
  7. COMMAND_UNKNOW(0),
  8. /**
  9. * <pre>
  10. *握手请求,含http的websocket握手请求
  11. * </pre>
  12. *
  13. * <code>COMMAND_HANDSHAKE_REQ = 1;</code>
  14. */
  15. COMMAND_HANDSHAKE_REQ(1),
  16. /**
  17. * <pre>
  18. *握手响应,含http的websocket握手响应
  19. * </pre>
  20. *
  21. * <code>COMMAND_HANDSHAKE_RESP = 2;</code>
  22. */
  23. COMMAND_HANDSHAKE_RESP(2),
  24. /**
  25. * <pre>
  26. *鉴权请求
  27. * </pre>
  28. *
  29. * <code>COMMAND_AUTH_REQ = 3;</code>
  30. */
  31. COMMAND_AUTH_REQ(3),
  32. /**
  33. * <pre>
  34. * 鉴权响应
  35. * </pre>
  36. *
  37. * <code>COMMAND_AUTH_RESP = 4;</code>
  38. */
  39. COMMAND_AUTH_RESP(4),
  40. /**
  41. * <pre>
  42. *登录请求
  43. * </pre>
  44. *
  45. * <code>COMMAND_LOGIN_REQ = 5;</code>
  46. */
  47. COMMAND_LOGIN_REQ(5),
  48. /**
  49. * <pre>
  50. *登录响应
  51. * </pre>
  52. *
  53. * <code>COMMAND_LOGIN_RESP = 6;</code>
  54. */
  55. COMMAND_LOGIN_RESP(6),
  56. /**
  57. * <pre>
  58. *申请进入群组
  59. * </pre>
  60. *
  61. * <code>COMMAND_JOIN_GROUP_REQ = 7;</code>
  62. */
  63. COMMAND_JOIN_GROUP_REQ(7),
  64. /**
  65. * <pre>
  66. *申请进入群组响应
  67. * </pre>
  68. *
  69. * <code>COMMAND_JOIN_GROUP_RESP = 8;</code>
  70. */
  71. COMMAND_JOIN_GROUP_RESP(8),
  72. /**
  73. * <pre>
  74. *进入群组通知
  75. * </pre>
  76. *
  77. * <code>COMMAND_JOIN_GROUP_NOTIFY_RESP = 9;</code>
  78. */
  79. COMMAND_JOIN_GROUP_NOTIFY_RESP(9),
  80. /**
  81. * <pre>
  82. *退出群组通知
  83. * </pre>
  84. *
  85. * <code>COMMAND_EXIT_GROUP_NOTIFY_RESP = 10;</code>
  86. */
  87. COMMAND_EXIT_GROUP_NOTIFY_RESP(10),
  88. /**
  89. * <pre>
  90. *聊天请求
  91. * </pre>
  92. *
  93. * <code>COMMAND_CHAT_REQ = 11;</code>
  94. */
  95. COMMAND_CHAT_REQ(11),
  96. /**
  97. * <pre>
  98. *聊天响应
  99. * </pre>
  100. *
  101. * <code>COMMAND_CHAT_RESP = 12;</code>
  102. */
  103. COMMAND_CHAT_RESP(12),
  104. /**
  105. * <pre>
  106. *心跳请求
  107. * </pre>
  108. *
  109. * <code>COMMAND_HEARTBEAT_REQ = 13;</code>
  110. */
  111. COMMAND_HEARTBEAT_REQ(13),
  112. /**
  113. * <pre>
  114. *关闭请求
  115. * </pre>
  116. *
  117. * <code>COMMAND_CLOSE_REQ = 14;</code>
  118. */
  119. COMMAND_CLOSE_REQ(14),
  120. /**
  121. * <pre>
  122. *发出撤消消息指令(管理员可以撤消所有人的消息,自己可以撤消自己的消息)
  123. * </pre>
  124. *
  125. * <code>COMMAND_CANCEL_MSG_REQ = 15;</code>
  126. */
  127. COMMAND_CANCEL_MSG_REQ(15),
  128. /**
  129. * <pre>
  130. *收到撤消消息指令
  131. * </pre>
  132. *
  133. * <code>COMMAND_CANCEL_MSG_RESP = 16;</code>
  134. */
  135. COMMAND_CANCEL_MSG_RESP(16),
  136. /**
  137. * <pre>
  138. *获取用户信息;
  139. * </pre>
  140. *
  141. * <code>COMMAND_GET_USER_REQ = 17;</code>
  142. */
  143. COMMAND_GET_USER_REQ(17),
  144. /**
  145. * <pre>
  146. *获取用户信息响应;
  147. * </pre>
  148. *
  149. * <code>COMMAND_GET_USER_RESP = 18;</code>
  150. */
  151. COMMAND_GET_USER_RESP(18),
  152. /**
  153. * <pre>
  154. * 获取聊天消息;
  155. * </pre>
  156. *
  157. * <code>COMMAND_GET_MESSAGE_REQ = 19;</code>
  158. */
  159. COMMAND_GET_MESSAGE_REQ(19),
  160. /**
  161. * <pre>
  162. * 获取聊天消息响应;
  163. * </pre>
  164. *
  165. * <code>COMMAND_GET_MESSAGE_RESP = 20;</code>
  166. */
  167. COMMAND_GET_MESSAGE_RESP(20),
  168. /**
  169. * 输入指示器 请求;
  170. */
  171. COMMAND_INPUT_POINTER_REQ(21),
  172. /**
  173. * 输入指示器 响应;
  174. */
  175. COMMAND_INPUT_POINTER_RESP(22),
  176. ;
  177. public final int getNumber() {
  178. return value;
  179. }
  180. public static Command valueOf(int value) {
  181. return forNumber(value);
  182. }
  183. public static Command forNumber(int value) {
  184. for(Command command : Command.values()){
  185. if(command.getNumber() == value){
  186. return command;
  187. }
  188. }
  189. return null;
  190. }
  191. public static Command addAndGet(String name , int value){
  192. return DynamicEnumUtil.addEnum(Command.class, name,new Class[]{int.class}, new Object[]{value});
  193. }
  194. private final int value;
  195. private Command(int value) {
  196. this.value = value;
  197. }
  198. }