refactor: add getter/setter for isConnected
This commit is contained in:
parent
3c1a9cc526
commit
a785031255
10
net/peer.go
10
net/peer.go
|
@ -39,6 +39,8 @@ type Peer interface {
|
|||
Challenge() []byte
|
||||
SetSocket(socket interface{})
|
||||
Socket() interface{}
|
||||
SetConnected(isConnected bool)
|
||||
IsConnected() bool
|
||||
}
|
||||
|
||||
type BasePeer struct {
|
||||
|
@ -49,6 +51,14 @@ type BasePeer struct {
|
|||
id *encoding.NodeId
|
||||
}
|
||||
|
||||
func (b *BasePeer) IsConnected() bool {
|
||||
return b.isConnected
|
||||
}
|
||||
|
||||
func (b *BasePeer) SetConnected(isConnected bool) {
|
||||
b.isConnected = isConnected
|
||||
}
|
||||
|
||||
func (b *BasePeer) SendMessage(message []byte) error {
|
||||
panic("must implement in child class")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue