···55 "sync"
66)
7788+// Peer represents a remote connection to the server such as a publisher or subscriber
89type Peer struct {
910 conn net.Conn
1011 connMu sync.Mutex
1112}
12131414+// New returns a new peer
1315func New(conn net.Conn) *Peer {
1416 return &Peer{
1517 conn: conn,
1618 }
1719}
18202121+// Addr returns the peers connections address
1922func (p *Peer) Addr() net.Addr {
2023 return p.conn.RemoteAddr()
2124}
22252626+// ConnOpp represents a set of actions on a connection that can be used synchrnously
2327type ConnOpp func(conn net.Conn) error
24282525-func (p *Peer) ConnOperation(op ConnOpp) error {
2929+// RunConnOperation will run the provided operation. It ensures that it is the only operation that is being
3030+// run on the connection to ensure any other operations don't get mixed up.
3131+func (p *Peer) RunConnOperation(op ConnOpp) error {
2632 p.connMu.Lock()
2733 defer p.connMu.Unlock()
2834