ZoaAnnouncementWS.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * 版权所有 (C) 2015 知启蒙(ZHIQIM) 保留所有权利。[遇见知启蒙,邂逅框架梦]
  3. *
  4. * 知启蒙WEB容器(zhiqim_httpd)在LGPL3.0协议下开源:https://www.zhiqim.com/gitcan/zhiqim/zhiqim_httpd.htm
  5. *
  6. * This file is part of [zhiqim_httpd].
  7. *
  8. * [zhiqim_httpd] is free software: you can redistribute
  9. * it and/or modify it under the terms of the GNU Lesser General Public License
  10. * as published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * [zhiqim_httpd] is distributed in the hope that it will
  14. * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public License
  19. * along with [zhiqim_httpd].
  20. * If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. package org.zhiqim.announcement;
  23. import org.zhiqim.httpd.HttpSession;
  24. import org.zhiqim.httpd.HttpSessionUser;
  25. import org.zhiqim.httpd.HttpWebsocket;
  26. import org.zhiqim.httpd.HttpWebsocketConnection;
  27. import org.zhiqim.kernel.annotation.AnAlias;
  28. import org.zhiqim.kernel.util.Ids;
  29. @AnAlias("zoa_announcement")
  30. public class ZoaAnnouncementWS implements HttpWebsocket
  31. {
  32. @Override
  33. public void onOpen(HttpWebsocketConnection conn)
  34. {
  35. HttpSessionUser sessionUser = conn.getSession().getSessionUser();
  36. if (sessionUser == null)
  37. {
  38. return;
  39. }
  40. }
  41. @Override
  42. public void onClose(HttpWebsocketConnection conn)
  43. {
  44. HttpSessionUser sessionUser = conn.getSession().getSessionUser();
  45. if (sessionUser == null)
  46. {
  47. return;
  48. }
  49. }
  50. @Override
  51. public void onException(HttpWebsocketConnection conn, Throwable e)
  52. {
  53. HttpSessionUser sessionUser = conn.getSession().getSessionUser();
  54. if (sessionUser == null)
  55. {
  56. return;
  57. }
  58. }
  59. @Override
  60. public void onMessage(HttpWebsocketConnection conn, String message)
  61. {
  62. HttpSession session = conn.getSession();
  63. HttpSessionUser sessionUser = session.getSessionUser();
  64. if (sessionUser == null)
  65. {
  66. return;
  67. }
  68. conn.send("" + Ids.longId());
  69. }
  70. @Override
  71. public void onMessage(HttpWebsocketConnection conn, byte[] message)
  72. {
  73. HttpSessionUser sessionUser = conn.getSession().getSessionUser();
  74. if (sessionUser == null)
  75. {
  76. return;
  77. }
  78. conn.send("" + Ids.longId());
  79. }
  80. }