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