ghttp_server_websocket.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2018 gf Author(https://github.com/gogf/gf). All Rights Reserved.
  2. //
  3. // This Source Code Form is subject to the terms of the MIT License.
  4. // If a copy of the MIT was not distributed with this file,
  5. // You can obtain one at https://github.com/gogf/gf.
  6. package ghttp
  7. import "github.com/gorilla/websocket"
  8. // WebSocket wraps the underlying websocket connection
  9. // and provides convenient functions.
  10. type WebSocket struct {
  11. *websocket.Conn
  12. }
  13. const (
  14. // TextMessage denotes a text data message. The text message payload is
  15. // interpreted as UTF-8 encoded text data.
  16. WS_MSG_TEXT = websocket.TextMessage
  17. // BinaryMessage denotes a binary data message.
  18. WS_MSG_BINARY = websocket.BinaryMessage
  19. // CloseMessage denotes a close control message. The optional message
  20. // payload contains a numeric code and text. Use the FormatCloseMessage
  21. // function to format a close message payload.
  22. WS_MSG_CLOSE = websocket.CloseMessage
  23. // PingMessage denotes a ping control message. The optional message payload
  24. // is UTF-8 encoded text.
  25. WS_MSG_PING = websocket.PingMessage
  26. // PongMessage denotes a pong control message. The optional message payload
  27. // is UTF-8 encoded text.
  28. WS_MSG_PONG = websocket.PongMessage
  29. )