MCPcopy
hub / github.com/aceld/zinx / NewWsClient

Function NewWsClient

znet/client.go:88–111  ·  view source on GitHub ↗
(ip string, port int, opts ...ClientOption)

Source from the content-addressed store, hash-verified

86}
87
88func NewWsClient(ip string, port int, opts ...ClientOption) ziface.IClient {
89
90 c := &Client{
91 // Default name, can be modified using the WithNameClient Option
92 // (默认名称,可以使用WithNameClient的Option修改)
93 Name: "ZinxClientWs",
94 Ip: ip,
95 Port: port,
96
97 msgHandler: newCliMsgHandle(),
98 packet: zpack.Factory().NewPack(ziface.ZinxDataPack), // Default to using Zinx's TLV packet format(默认使用zinx的TLV封包方式)
99 decoder: zdecoder.NewTLVDecoder(), // Default to using Zinx's TLV decoder(默认使用zinx的TLV解码器)
100 version: "websocket",
101 dialer: &websocket.Dialer{},
102 errChan: make(chan error, 1),
103 }
104
105 // Apply Option settings (应用Option设置)
106 for _, opt := range opts {
107 opt(c)
108 }
109
110 return c
111}
112
113func NewTLSClient(ip string, port int, opts ...ClientOption) ziface.IClient {
114

Callers 1

mainFunction · 0.92

Calls 4

FactoryFunction · 0.92
NewTLVDecoderFunction · 0.92
newCliMsgHandleFunction · 0.85
NewPackMethod · 0.80

Tested by

no test coverage detected