Implement backend.Stdout that can be subscribed/unsubscribed.

This commit is contained in:
Kleissner
2022-01-06 04:11:28 +01:00
parent a19bac1916
commit 5c8b8eb94b
3 changed files with 51 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ package core
import (
"bytes"
"encoding/hex"
"fmt"
"github.com/PeernetOfficial/core/dht"
@@ -214,7 +215,7 @@ func (peer *PeerInfo) cmdPong(msg *protocol.MessageRaw, connection *Connection)
// cmdChat handles a chat message [debug]
func (peer *PeerInfo) cmdChat(msg *protocol.MessageRaw, connection *Connection) {
fmt.Printf("Chat from '%s': %s\n", connection.Address.String(), string(msg.PacketRaw.Payload))
fmt.Fprintf(peer.Backend.Stdout, "Chat from %s '%s': %s\n", hex.EncodeToString(peer.PublicKey.SerializeCompressed()), connection.Address.String(), string(msg.PacketRaw.Payload))
}
// cmdLocalDiscovery handles an incoming announcement via local discovery