(ip string, port int, opts ...ClientOption)
| 86 | } |
| 87 | |
| 88 | func 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 | |
| 113 | func NewTLSClient(ip string, port int, opts ...ClientOption) ziface.IClient { |
| 114 |
no test coverage detected