ghttp_client_websocket.go 759 B

1234567891011121314151617181920212223242526272829
  1. // Copyright GoFrame Author(https://goframe.org). 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 (
  8. "github.com/gorilla/websocket"
  9. "net/http"
  10. "time"
  11. )
  12. // WebSocketClient wraps the underlying websocket client connection
  13. // and provides convenient functions.
  14. type WebSocketClient struct {
  15. *websocket.Dialer
  16. }
  17. // NewWebSocketClient New creates and returns a new WebSocketClient object.
  18. func NewWebSocketClient() *WebSocketClient {
  19. return &WebSocketClient{
  20. &websocket.Dialer{
  21. Proxy: http.ProxyFromEnvironment,
  22. HandshakeTimeout: 45 * time.Second,
  23. },
  24. }
  25. }