(ip string, port int, opts ...ClientOption)
| 62 | } |
| 63 | |
| 64 | func NewClient(ip string, port int, opts ...ClientOption) ziface.IClient { |
| 65 | |
| 66 | c := &Client{ |
| 67 | // Default name, can be modified using the WithNameClient Option |
| 68 | // (默认名称,可以使用WithNameClient的Option修改) |
| 69 | Name: "ZinxClientTcp", |
| 70 | Ip: ip, |
| 71 | Port: port, |
| 72 | |
| 73 | msgHandler: newCliMsgHandle(), |
| 74 | packet: zpack.Factory().NewPack(ziface.ZinxDataPack), // Default to using Zinx's TLV packet format(默认使用zinx的TLV封包方式) |
| 75 | decoder: zdecoder.NewTLVDecoder(), // Default to using Zinx's TLV decoder(默认使用zinx的TLV解码器) |
| 76 | version: "tcp", |
| 77 | errChan: make(chan error, 1), |
| 78 | } |
| 79 | |
| 80 | // Apply Option settings (应用Option设置) |
| 81 | for _, opt := range opts { |
| 82 | opt(c) |
| 83 | } |
| 84 | |
| 85 | return c |
| 86 | } |
| 87 | |
| 88 | func NewWsClient(ip string, port int, opts ...ClientOption) ziface.IClient { |
| 89 |
no test coverage detected