mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2025-10-28 07:15:34 -07:00
Allow transports to define their own ping mechanism
This commit is contained in:
committed by
Mickaël Rémond
parent
d0f2b492ac
commit
36e153f981
@@ -2,6 +2,7 @@ package xmpp
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
@@ -59,6 +60,17 @@ func (t *XMPPTransport) StartTLS(domain string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t XMPPTransport) Ping() error {
|
||||
n, err := t.conn.Write([]byte("\n"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if n != 1 {
|
||||
return errors.New("Could not write ping")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t XMPPTransport) Read(p []byte) (n int, err error) {
|
||||
return t.conn.Read(p)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user