github.com/gogf/gf@v1.16.9/net/ghttp/ghttp_client_websocket.go (about) 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 7 package ghttp 8 9 import ( 10 "github.com/gorilla/websocket" 11 "net/http" 12 "time" 13 ) 14 15 // WebSocketClient wraps the underlying websocket client connection 16 // and provides convenient functions. 17 type WebSocketClient struct { 18 *websocket.Dialer 19 } 20 21 // NewWebSocketClient New creates and returns a new WebSocketClient object. 22 func NewWebSocketClient() *WebSocketClient { 23 return &WebSocketClient{ 24 &websocket.Dialer{ 25 Proxy: http.ProxyFromEnvironment, 26 HandshakeTimeout: 45 * time.Second, 27 }, 28 } 29 }