gclient
14 分钟阅读
原文:https://pkg.go.dev/github.com/gogf/gf/v2@v2.6.4/net/gclient
Package gclient provides convenient http client functionalities.
软件包 gclient 提供了方便的 http 客户端功能。
常量
This section is empty.
变量
This section is empty.
函数
func LoadKeyCrt
|
|
LoadKeyCrt creates and returns a TLS configuration object with given certificate and key files.
LoadKeyCrt 创建并返回具有给定证书和密钥文件的 TLS 配置对象。
类型
type Client
|
|
Client is the HTTP client for HTTP request management.
客户端是用于 HTTP 请求管理的 HTTP 客户端。
func New
|
|
New creates and returns a new HTTP client object.
new 创建并返回新的 HTTP 客户端对象。
Example
|
|
(*Client) BasicAuth
|
|
BasicAuth is a chaining function, which sets HTTP basic authentication information for next request.
BasicAuth 是一个链接函数,用于设置下一个请求的 HTTP 基本身份验证信息。
(*Client) Clone
|
|
Clone deeply clones current client and returns a new one.
克隆会深度克隆当前客户端并返回一个新客户端。
Example
|
|
(*Client) Connect
|
|
Connect send CONNECT request and returns the response object. Note that the response object MUST be closed if it’ll never be used.
连接:发送 CONNECT 请求并返回响应对象。请注意,如果响应对象永远不会被使用,则必须将其关闭。
Example
|
|
(*Client) ConnectBytes
|
|
ConnectBytes sends a CONNECT request, retrieves and returns the result content as bytes.
ConnectBytes 发送 CONNECT 请求,检索结果内容并以字节形式返回。
Example
|
|
(*Client) ConnectContent
|
|
ConnectContent is a convenience method for sending CONNECT request, which retrieves and returns the result content and automatically closes response object.
ConnectContent 是一种发送 CONNECT 请求的便捷方式,用于检索并返回结果内容并自动关闭响应对象。
Example
|
|
(*Client) ConnectVar
|
|
ConnectVar sends a CONNECT request, retrieves and converts the result content to *gvar.Var. The client reads and closes the response object internally automatically. The result *gvar.Var can be conveniently converted to any type you want.
ConnectVar 发送 CONNECT 请求,检索结果内容并将其转换为 *gvar.Var。客户端在内部自动读取和关闭响应对象。结果 *gvar.Var 可以方便地转换为您想要的任何类型。
Example
|
|
(*Client) ContentJson
|
|
ContentJson is a chaining function, which sets the HTTP content type as “application/json” for the next request.
ContentJson 是一个链接函数,它将下一个请求的 HTTP 内容类型设置为“application/json”。
Note that it also checks and encodes the parameter to JSON format automatically.
请注意,它还会自动检查参数并将其编码为 JSON 格式。
Example
|
|
(*Client) ContentType
|
|
ContentType is a chaining function, which sets HTTP content type for the next request.
ContentType 是一个链接函数,用于设置下一个请求的 HTTP 内容类型。
(*Client) ContentXml
|
|
ContentXml is a chaining function, which sets the HTTP content type as “application/xml” for the next request.
ContentXml 是一个链接函数,它将下一个请求的 HTTP 内容类型设置为“application/xml”。
Note that it also checks and encodes the parameter to XML format automatically.
请注意,它还会自动检查参数并将其编码为 XML 格式。
(*Client) Cookie
|
|
Cookie is a chaining function, which sets cookie items with map for next request.
Cookie 是一种链接功能,它为下一个请求设置带有映射的 cookie 项。
Example
|
|
(*Client) Delete
|
|
Delete send DELETE request and returns the response object. Note that the response object MUST be closed if it’ll never be used.
删除发送 DELETE 请求并返回响应对象。请注意,如果响应对象永远不会被使用,则必须将其关闭。
Example
|
|
(*Client) DeleteBytes
|
|
DeleteBytes sends a DELETE request, retrieves and returns the result content as bytes.
DeleteBytes 发送 DELETE 请求,检索结果内容并以字节形式返回。
Example
|
|
(*Client) DeleteContent
|
|
DeleteContent is a convenience method for sending DELETE request, which retrieves and returns the result content and automatically closes response object.
DeleteContent 是一种发送 DELETE 请求的便捷方式,用于检索并返回结果内容并自动关闭响应对象。
Example
|
|
(*Client) DeleteVar
|
|
DeleteVar sends a DELETE request, retrieves and converts the result content to *gvar.Var. The client reads and closes the response object internally automatically. The result *gvar.Var can be conveniently converted to any type you want.
DeleteVar 发送 DELETE 请求,检索结果内容并将其转换为 *gvar.Var。客户端在内部自动读取和关闭响应对象。结果 *gvar.Var 可以方便地转换为您想要的任何类型。
Example
|
|
(*Client) Discovery
|
|
Discovery is a chaining function, which sets the discovery for client. You can use Discovery(nil)
to disable discovery feature for current client.
发现是一个链接函数,用于设置客户端的发现。您可以使用 Discovery(nil)
禁用当前客户端的发现功能。
(*Client) DoRequest
|
|
DoRequest sends request with given HTTP method and data and returns the response object. Note that the response object MUST be closed if it’ll never be used.
DoRequest 使用给定的 HTTP 方法和数据发送请求,并返回响应对象。请注意,如果响应对象永远不会被使用,则必须将其关闭。
Note that it uses “multipart/form-data” as its Content-Type if it contains file uploading, else it uses “application/x-www-form-urlencoded”. It also automatically detects the post content for JSON format, and for that it automatically sets the Content-Type as “application/json”.
请注意,如果它包含文件上传,则它使用“multipart/form-data”作为其内容类型,否则它使用“application/x-www-form-urlencoded”。它还会自动检测 JSON 格式的帖子内容,并为此自动将 Content-Type 设置为“application/json”。
(*Client) DoRequestObj
|
|
DoRequestObj does HTTP request using standard request/response object. The request object req
is defined like:
DoRequestObj 使用标准请求/响应对象执行 HTTP 请求。请求对象 req
的定义如下:
|
|
The response object res
should be a pointer type. It automatically converts result to given object res
is success.
响应对象 res
应为指针类型。它会自动将结果转换为给定对象 res
即成功。
Example: var (
示例:var (
req = UseCreateReq{}
res *UseCreateRes
)
err := DoRequestObj(ctx, req, &res)
err := DoRequestObj(ctx, req, &res)
(*Client) Get
|
|
Get send GET request and returns the response object. Note that the response object MUST be closed if it’ll never be used.
获取发送 GET 请求并返回响应对象。请注意,如果响应对象永远不会被使用,则必须将其关闭。
Example
|
|
(*Client) GetBytes
|
|
GetBytes sends a GET request, retrieves and returns the result content as bytes.
GetBytes 发送 GET 请求,检索结果内容并以字节形式返回。
Example
|
|
(*Client) GetContent
|
|
GetContent is a convenience method for sending GET request, which retrieves and returns the result content and automatically closes response object.
GetContent 是一种发送 GET 请求的便捷方式,它检索并返回结果内容并自动关闭响应对象。
Example
|
|
(*Client) GetVar
|
|
GetVar sends a GET request, retrieves and converts the result content to *gvar.Var. The client reads and closes the response object internally automatically. The result *gvar.Var can be conveniently converted to any type you want.
GetVar 发送 GET 请求,检索结果内容并将其转换为 *gvar.Var。客户端在内部自动读取和关闭响应对象。结果 *gvar.Var 可以方便地转换为您想要的任何类型。
Example
|
|
(*Client) Head
|
|
Head send HEAD request and returns the response object. Note that the response object MUST be closed if it’ll never be used.
head 发送 HEAD 请求并返回响应对象。请注意,如果响应对象永远不会被使用,则必须将其关闭。
Example
|
|
(*Client) HeadBytes
|
|
HeadBytes sends a HEAD request, retrieves and returns the result content as bytes.
HeadBytes 发送 HEAD 请求,检索结果内容并以字节形式返回。
Example
|
|
(*Client) HeadContent
|
|
HeadContent is a convenience method for sending HEAD request, which retrieves and returns the result content and automatically closes response object.
HeadContent 是一种发送 HEAD 请求的便捷方式,它检索并返回结果内容,并自动关闭响应对象。
Example
|
|
(*Client) HeadVar
|
|
HeadVar sends a HEAD request, retrieves and converts the result content to *gvar.Var. The client reads and closes the response object internally automatically. The result *gvar.Var can be conveniently converted to any type you want.
HeadVar 发送 HEAD 请求,检索结果内容并将其转换为 *gvar.Var。客户端在内部自动读取和关闭响应对象。结果 *gvar.Var 可以方便地转换为您想要的任何类型。
Example
|
|
(*Client) Header
|
|
Header is a chaining function, which sets custom HTTP headers with map for next request.
Header 是一个链接函数,它为下一个请求设置带有 map 的自定义 HTTP 标头。
Example
|
|
(*Client) HeaderRaw
|
|
HeaderRaw is a chaining function, which sets custom HTTP header using raw string for next request.
HeaderRaw 是一个链接函数,它使用原始字符串为下一个请求设置自定义 HTTP 标头。
Example
|
|
(*Client) Next
|
|
Next calls the next middleware. This should only be call in HandlerFunc.
接下来调用下一个中间件。这应该只在 HandlerFunc 中调用。
(*Client) NoUrlEncode
|
|
NoUrlEncode sets the mark that do not encode the parameters before sending request.
NoUrlEncode 设置在发送请求之前不对参数进行编码的标记。
(*Client) Options
|
|
Options send OPTIONS request and returns the response object. Note that the response object MUST be closed if it’ll never be used.
Options 发送 OPTIONS 请求并返回响应对象。请注意,如果响应对象永远不会被使用,则必须将其关闭。
Example
|
|
(*Client) OptionsBytes
|
|
OptionsBytes sends an OPTIONS request, retrieves and returns the result content as bytes.
OptionsBytes 发送 OPTIONS 请求,检索结果内容并以字节形式返回。
Example
|
|
(*Client) OptionsContent
|
|
OptionsContent is a convenience method for sending OPTIONS request, which retrieves and returns the result content and automatically closes response object.
OptionsContent 是一种发送 OPTIONS 请求的便捷方式,它检索并返回结果内容并自动关闭响应对象。
Example
|
|
(*Client) OptionsVar
|
|
OptionsVar sends an OPTIONS request, retrieves and converts the result content to *gvar.Var. The client reads and closes the response object internally automatically. The result *gvar.Var can be conveniently converted to any type you want.
OptionsVar 发送 OPTIONS 请求,检索结果内容并将其转换为 *gvar.Var。客户端在内部自动读取和关闭响应对象。结果 *gvar.Var 可以方便地转换为您想要的任何类型。
Example
|
|
(*Client) Patch
|
|
Patch send PATCH request and returns the response object. Note that the response object MUST be closed if it’ll never be used.
Patch 发送 PATCH 请求并返回响应对象。请注意,如果响应对象永远不会被使用,则必须将其关闭。
Example
|
|
(*Client) PatchBytes
|
|
PatchBytes sends a PATCH request, retrieves and returns the result content as bytes.
PatchBytes 发送 PATCH 请求,检索结果内容并以字节形式返回。
Example
|
|
(*Client) PatchContent
|
|
PatchContent is a convenience method for sending PATCH request, which retrieves and returns the result content and automatically closes response object.
PatchContent 是一种发送 PATCH 请求的便捷方式,它检索并返回结果内容并自动关闭响应对象。
Example
|
|
(*Client) PatchVar
|
|
PatchVar sends a PATCH request, retrieves and converts the result content to *gvar.Var. The client reads and closes the response object internally automatically. The result *gvar.Var can be conveniently converted to any type you want.
PatchVar 发送 PATCH 请求,检索结果内容并将其转换为 *gvar.Var。客户端在内部自动读取和关闭响应对象。结果 *gvar.Var 可以方便地转换为您想要的任何类型。
Example
|
|
(*Client) Post
|
|
Post sends request using HTTP method POST and returns the response object. Note that the response object MUST be closed if it’ll never be used.
POST 使用 HTTP 方法 POST 发送请求并返回响应对象。请注意,如果响应对象永远不会被使用,则必须将其关闭。
Example
|
|
(*Client) PostBytes
|
|
PostBytes sends a POST request, retrieves and returns the result content as bytes.
PostBytes 发送 POST 请求,检索结果内容并以字节形式返回。
Example
|
|
(*Client) PostContent
|
|
PostContent is a convenience method for sending POST request, which retrieves and returns the result content and automatically closes response object.
PostContent 是一种发送 POST 请求的便捷方式,用于检索并返回结果内容并自动关闭响应对象。
Example
|
|
(*Client) PostForm
|
|
PostForm is different from net/http.PostForm. It’s a wrapper of Post method, which sets the Content-Type as “multipart/form-data;”. and It will automatically set boundary characters for the request body and Content-Type.
PostForm 与 net/http 不同。PostForm的。它是 Post 方法的包装器,它将 Content-Type 设置为“multipart/form-data;”。它将自动为请求正文和 Content-Type 设置边界字符。
It’s Seem like the following case:
这似乎是以下情况:
Content-Type: multipart/form-data; boundary=—-Boundarye4Ghaog6giyQ9ncN
内容类型:multipart/form-data;boundary=—-Boundarye4Ghaog6giyQ9ncN
And form data is like: ——Boundarye4Ghaog6giyQ9ncN Content-Disposition: form-data; name=“checkType”
而表单数据是这样的: ——Boundarye4Ghaog6giyQ9ncN Content-Disposition: form-data;名称=“checkType”
none
没有
It’s used for sending form data. Note that the response object MUST be closed if it’ll never be used.
它用于发送表单数据。请注意,如果响应对象永远不会被使用,则必须将其关闭。
(*Client) PostVar
|
|
PostVar sends a POST request, retrieves and converts the result content to *gvar.Var. The client reads and closes the response object internally automatically. The result *gvar.Var can be conveniently converted to any type you want.
PostVar 发送 POST 请求,检索结果内容并将其转换为 *gvar.Var。客户端在内部自动读取和关闭响应对象。结果 *gvar.Var 可以方便地转换为您想要的任何类型。
Example
|
|
(*Client) Prefix
|
|
Prefix is a chaining function, which sets the URL prefix for next request of this client. Eg: Prefix(“http://127.0.0.1:8199/api/v1”) Prefix(“http://127.0.0.1:8199/api/v2”)
Prefix 是一个链接函数,它为该客户端的下一个请求设置 URL 前缀。例如:prefix(“http://127.0.0.1:8199/api/v1”) prefix(“http://127.0.0.1:8199/api/v2”)
Example
|
|
(*Client) Proxy
|
|
Proxy is a chaining function, which sets proxy for next request. Make sure you pass the correct proxyURL
. The correct pattern is like [http://USER:PASSWORD@IP:PORT](http://USER:PASSWORD@ip:PORT/)
or socks5://USER:PASSWORD@IP:PORT
. Only http
and socks5
proxies are supported currently.
Proxy 是一个链接函数,它为下一个请求设置代理。确保通过正确的 proxyURL
.正确的模式是 like [http://USER:PASSWORD@IP:PORT](http://USER:PASSWORD@ip:PORT/)
或 socks5://USER:PASSWORD@IP:PORT
。目前仅 http
支持代理和 socks5
代理。
Example
|
|
(*Client) Put
|
|
Put send PUT request and returns the response object. Note that the response object MUST be closed if it’ll never be used.
put send PUT 请求并返回响应对象。请注意,如果响应对象永远不会被使用,则必须将其关闭。
Example
|
|
(*Client) PutBytes
|
|
PutBytes sends a PUT request, retrieves and returns the result content as bytes.
PutBytes 发送 PUT 请求,检索结果内容并以字节形式返回。
Example
|
|
(*Client) PutContent
|
|
PutContent is a convenience method for sending PUT request, which retrieves and returns the result content and automatically closes response object.
PutContent 是一种发送 PUT 请求的便捷方式,用于检索并返回结果内容并自动关闭响应对象。
Example
|
|
(*Client) PutVar
|
|
PutVar sends a PUT request, retrieves and converts the result content to *gvar.Var. The client reads and closes the response object internally automatically. The result *gvar.Var can be conveniently converted to any type you want.
PutVar 发送 PUT 请求,检索结果内容并将其转换为 *gvar.Var。客户端在内部自动读取和关闭响应对象。结果 *gvar.Var 可以方便地转换为您想要的任何类型。
Example
|
|
(*Client) RedirectLimit
|
|
RedirectLimit is a chaining function, which sets the redirect limit the number of jumps for the request.
RedirectLimit 是一个链接函数,它设置重定向限制请求的跳转次数。
Example
|
|
(*Client) RequestBytes
|
|
RequestBytes sends request using given HTTP method and data, retrieves returns the result as bytes. It reads and closes the response object internally automatically.
RequestBytes 使用给定的 HTTP 方法和数据发送请求,检索以字节形式返回结果。它会在内部自动读取和关闭响应对象。
(*Client) RequestContent
|
|
RequestContent is a convenience method for sending custom http method request, which retrieves and returns the result content and automatically closes response object.
RequestContent 是一种发送自定义 http 方法请求的便捷方式,用于检索并返回结果内容并自动关闭响应对象。
Example
|
|
(*Client) RequestVar
|
|
RequestVar sends request using given HTTP method and data, retrieves converts the result to *gvar.Var. The client reads and closes the response object internally automatically. The result *gvar.Var can be conveniently converted to any type you want.
RequestVar 使用给定的 HTTP 方法和数据发送请求,检索将结果转换为 *gvar.Var。客户端在内部自动读取和关闭响应对象。结果 *gvar.Var 可以方便地转换为您想要的任何类型。
(*Client) Retry
|
|
Retry is a chaining function, which sets retry count and interval when failure for next request.
重试是一个链接函数,用于设置下一个请求失败时的重试计数和间隔。
Example
|
|
(*Client) SetAgent
|
|
SetAgent sets the User-Agent header for client.
SetAgent 为客户端设置 User-Agent 标头。
(*Client) SetBasicAuth
|
|
SetBasicAuth sets HTTP basic authentication information for the client.
SetBasicAuth 设置客户端的 HTTP 基本身份验证信息。
(*Client) SetBrowserMode
|
|
SetBrowserMode enables browser mode of the client. When browser mode is enabled, it automatically saves and sends cookie content from and to server.
SetBrowserMode 启用客户端的浏览器模式。启用浏览器模式后,它会自动保存和发送来自服务器和发送到服务器的 cookie 内容。
Example
|
|
(*Client) SetBuilder
|
|
SetBuilder sets the load balance builder for client.
SetBuilder 为客户端设置负载平衡生成器。
(*Client) SetContentType
|
|
SetContentType sets HTTP content type for the client.
SetContentType 设置客户端的 HTTP 内容类型。
(*Client) SetCookie
|
|
SetCookie sets a cookie pair for the client.
SetCookie 为客户端设置 Cookie 对。
(*Client) SetCookieMap
|
|
SetCookieMap sets cookie items with map.
SetCookieMap 使用 map 设置 cookie 项。
(*Client) SetDiscovery
|
|
SetDiscovery sets the load balance builder for client.
SetDiscovery 为客户端设置负载平衡生成器。
(*Client) SetHeader
|
|
SetHeader sets a custom HTTP header pair for the client.
SetHeader 为客户端设置自定义 HTTP 标头对。
Example
|
|
(*Client) SetHeaderMap
|
|
SetHeaderMap sets custom HTTP headers with map.
SetHeaderMap 使用 map 设置自定义 HTTP 标头。
(*Client) SetHeaderRaw
|
|
SetHeaderRaw sets custom HTTP header using raw string.
SetHeaderRaw 使用原始字符串设置自定义 HTTP 标头。
(*Client) SetNoUrlEncode
|
|
SetNoUrlEncode sets the mark that do not encode the parameters before sending request.
SetNoUrlEncode 设置在发送请求之前不对参数进行编码的标记。
(*Client) SetPrefix
|
|
SetPrefix sets the request server URL prefix.
SetPrefix 设置请求服务器 URL 前缀。
(*Client) SetProxy
|
|
SetProxy set proxy for the client. This func will do nothing when the parameter proxyURL
is empty or in wrong pattern. The correct pattern is like [http://USER:PASSWORD@IP:PORT](http://USER:PASSWORD@ip:PORT/)
or socks5://USER:PASSWORD@IP:PORT
. Only http
and socks5
proxies are supported currently.
SetProxy 为客户端设置代理。当参数 proxyURL
为空或模式错误时,此函数将不执行任何操作。正确的模式是 like [http://USER:PASSWORD@IP:PORT](http://USER:PASSWORD@ip:PORT/)
或 socks5://USER:PASSWORD@IP:PORT
。目前仅 http
支持代理和 socks5
代理。
Example
|
|
(*Client) SetRedirectLimit
|
|
SetRedirectLimit limits the number of jumps.
SetRedirectLimit 限制跳转次数。
Example
|
|
(*Client) SetRetry
|
|
SetRetry sets retry count and interval.
SetRetry 设置重试计数和间隔。
(*Client) SetTLSConfig
|
|
SetTLSConfig sets the TLS configuration of client.
SetTLSConfig 设置客户端的 TLS 配置。
Example
|
|
(*Client) SetTLSKeyCrt
|
|
SetTLSKeyCrt sets the certificate and key file for TLS configuration of client.
SetTLSKeyCrt 设置客户端 TLS 配置的证书和密钥文件。
Example
|
|
(*Client) SetTimeout
|
|
SetTimeout sets the request timeout for the client.
SetTimeout 设置客户端的请求超时。
(*Client) Timeout
|
|
Timeout is a chaining function, which sets the timeout for next request.
Timeout 是一个链接函数,用于设置下一个请求的超时。
(*Client) Trace
|
|
Trace send TRACE request and returns the response object. Note that the response object MUST be closed if it’ll never be used.
Trace 发送 TRACE 请求并返回响应对象。请注意,如果响应对象永远不会被使用,则必须将其关闭。
Example
|
|
(*Client) TraceBytes
|
|
TraceBytes sends a TRACE request, retrieves and returns the result content as bytes.
TraceBytes 发送 TRACE 请求,检索结果内容并以字节形式返回。
Example
|
|
(*Client) TraceContent
|
|
TraceContent is a convenience method for sending TRACE request, which retrieves and returns the result content and automatically closes response object.
TraceContent 是一种发送 TRACE 请求的便捷方式,用于检索并返回结果内容并自动关闭响应对象。
Example
|
|
(*Client) TraceVar
|
|
TraceVar sends a TRACE request, retrieves and converts the result content to *gvar.Var. The client reads and closes the response object internally automatically. The result *gvar.Var can be conveniently converted to any type you want.
TraceVar 发送 TRACE 请求,检索结果内容并将其转换为 *gvar.Var。客户端在内部自动读取和关闭响应对象。结果 *gvar.Var 可以方便地转换为您想要的任何类型。
Example
|
|
(*Client) Use
|
|
Use adds one or more middleware handlers to client.
Use 将一个或多个中间件处理程序添加到客户端。
type HandlerFunc
|
|
HandlerFunc middleware handler func
HandlerFunc 中间件处理程序 func
type Response
|
|
Response is the struct for client request response.
响应是客户端请求响应的结构。
(*Response) Close
|
|
Close closes the response when it will never be used.
关闭 (Close) 在永远不会使用的响应时关闭响应。
(*Response) GetCookie
|
|
GetCookie retrieves and returns the cookie value of specified key
.
GetCookie 检索并返回指定的 key
cookie 值。
(*Response) GetCookieMap
|
|
GetCookieMap retrieves and returns a copy of current cookie values map.
GetCookieMap 检索并返回当前 Cookie 值映射的副本。
(*Response) Raw
|
|
Raw returns the raw text of the request and the response.
Raw 返回请求和响应的原始文本。
(*Response) RawDump
|
|
RawDump outputs the raw text of the request and the response to stdout.
RawDump 输出请求的原始文本和对 stdout 的响应。
(*Response) RawRequest
|
|
RawRequest returns the raw content of the request.
RawRequest 返回请求的原始内容。
(*Response) RawResponse
|
|
RawResponse returns the raw content of the response.
RawResponse 返回响应的原始内容。
(*Response) ReadAll
|
|
ReadAll retrieves and returns the response content as []byte.
ReadAll 检索响应内容并以 []byte 的形式返回。
(*Response) ReadAllString
|
|
ReadAllString retrieves and returns the response content as string.
ReadAllString 检索响应内容并将其作为字符串返回。
(*Response) SetBodyContent
|
|
SetBodyContent overwrites response content with custom one.
SetBodyContent 使用自定义响应内容覆盖响应内容。
type WebSocketClient
|
|
WebSocketClient wraps the underlying websocket client connection and provides convenient functions.
WebSocketClient 包装底层 websocket 客户端连接,提供便捷的功能。
func NewWebSocket
|
|
NewWebSocket creates and returns a new WebSocketClient object.
NewWebSocket 创建并返回一个新的 WebSocketClient 对象。