implement ping
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m56s
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m56s
This commit is contained in:
@@ -48,10 +48,6 @@ func (m *TCPClient) Connect() error {
|
||||
if m.Conn == nil {
|
||||
connection, err := net.Dial("tcp", m.address)
|
||||
if err != nil {
|
||||
|
||||
m.Errors <- err
|
||||
m.ErrorCount++
|
||||
|
||||
return err
|
||||
}
|
||||
m.ErrorCount = 0
|
||||
@@ -60,6 +56,16 @@ func (m *TCPClient) Connect() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TCPClient) HandleConnectionError(err error) error {
|
||||
if err != nil {
|
||||
|
||||
m.Errors <- err
|
||||
m.ErrorCount++
|
||||
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *TCPClient) Close() {
|
||||
m.Conn.Close()
|
||||
}
|
||||
@@ -75,10 +81,10 @@ func (m *TCPClient) SendPacket(messageType uint16, data []byte) error {
|
||||
DataLength: uint16(len(data)),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
return m.HandleConnectionError(err)
|
||||
}
|
||||
_, err = m.Conn.Write(data)
|
||||
return err
|
||||
return m.HandleConnectionError(err)
|
||||
}
|
||||
|
||||
// func (m *TCPClient) SendPacketFn(messageType uint16, datafn func(w io.Writer) error) error {
|
||||
|
||||
Reference in New Issue
Block a user