2021-01-17 21:46:25 +08:00
|
|
|
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
2018-06-02 23:47:16 +08:00
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
2019-02-02 16:18:25 +08:00
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
2018-06-02 23:47:16 +08:00
|
|
|
|
|
|
|
package ghttp
|
|
|
|
|
2019-08-01 14:07:25 +08:00
|
|
|
import "github.com/gorilla/websocket"
|
2018-06-02 23:47:16 +08:00
|
|
|
|
2020-05-07 23:05:33 +08:00
|
|
|
// WebSocket wraps the underlying websocket connection
|
|
|
|
// and provides convenient functions.
|
2018-06-02 23:47:16 +08:00
|
|
|
type WebSocket struct {
|
2019-06-19 09:06:52 +08:00
|
|
|
*websocket.Conn
|
2018-08-31 23:53:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
2022-03-19 17:58:21 +08:00
|
|
|
// WsMsgText TextMessage denotes a text data message.
|
|
|
|
// The text message payload is interpreted as UTF-8 encoded text data.
|
2021-11-13 23:23:55 +08:00
|
|
|
WsMsgText = websocket.TextMessage
|
2019-06-19 09:06:52 +08:00
|
|
|
|
2021-11-13 23:23:55 +08:00
|
|
|
// WsMsgBinary BinaryMessage denotes a binary data message.
|
|
|
|
WsMsgBinary = websocket.BinaryMessage
|
2019-06-19 09:06:52 +08:00
|
|
|
|
2022-03-19 17:58:21 +08:00
|
|
|
// WsMsgClose CloseMessage denotes a close control message.
|
|
|
|
// The optional message payload contains a numeric code and text.
|
|
|
|
// Use the FormatCloseMessage function to format a close message payload.
|
2021-11-13 23:23:55 +08:00
|
|
|
WsMsgClose = websocket.CloseMessage
|
2019-06-19 09:06:52 +08:00
|
|
|
|
2022-03-19 17:58:21 +08:00
|
|
|
// WsMsgPing PingMessage denotes a ping control message.
|
|
|
|
// The optional message payload is UTF-8 encoded text.
|
2021-11-13 23:23:55 +08:00
|
|
|
WsMsgPing = websocket.PingMessage
|
2019-06-19 09:06:52 +08:00
|
|
|
|
2022-03-19 17:58:21 +08:00
|
|
|
// WsMsgPong PongMessage denotes a pong control message.
|
|
|
|
// The optional message payload is UTF-8 encoded text.
|
2021-11-13 23:23:55 +08:00
|
|
|
WsMsgPong = websocket.PongMessage
|
2019-06-19 09:06:52 +08:00
|
|
|
)
|