diff --git a/examples/chat2/chat.go b/examples/chat2/chat.go index 8bc090f..c9b5635 100644 --- a/examples/chat2/chat.go +++ b/examples/chat2/chat.go @@ -7,13 +7,14 @@ import ( "time" "log" + "github.com/ethereum/go-ethereum/rpc" "github.com/golang/protobuf/proto" "github.com/libp2p/go-libp2p-core/peer" "github.com/status-im/go-waku/waku/v2/node" wpb "github.com/status-im/go-waku/waku/v2/protocol/pb" "golang.org/x/crypto/pbkdf2" - "github.com/status-im/go-nwaku/nwaku" + // "github.com/status-im/go-nwaku/nwaku" ) // Chat represents a subscription to a single PubSub topic. Messages @@ -26,6 +27,7 @@ type Chat struct { sub *node.Subscription // TODO Replace with wrapper //node *node.WakuNode + client *rpc.Client self peer.ID contentTopic string @@ -35,7 +37,7 @@ type Chat struct { // NewChat tries to subscribe to the PubSub topic for the room name, returning // a ChatRoom on success. -func NewChat(selfID peer.ID, contentTopic string, useV1Payload bool, nickname string) (*Chat, error) { +func NewChat(client *rpc.Client, selfID peer.ID, contentTopic string, useV1Payload bool, nickname string) (*Chat, error) { // join the default waku topic and subscribe to it // TODO Do this with JSON RPC // sub, err := n.Subscribe(nil) diff --git a/examples/chat2/main.go b/examples/chat2/main.go index 49b7024..533bdd2 100644 --- a/examples/chat2/main.go +++ b/examples/chat2/main.go @@ -22,6 +22,8 @@ import ( // TODO Replace with wrapper // "github.com/status-im/go-waku/waku/v2/node" // "github.com/status-im/go-waku/waku/v2/protocol/store" + "github.com/ethereum/go-ethereum/rpc" + //"github.com/status-im/go-nwaku/nwaku" ) var DefaultContentTopic string = "/toy-chat/2/huilong/proto" @@ -62,6 +64,10 @@ func main() { log.Printf("NYI prvKey use", prvKey) + // TODO Start wrapper node + // Assumes node started + client, _ := rpc.Dial("http://127.0.0.1:8545") + ctx := context.Background() // TODO Replace with wrapper // wakuNode, err := node.New(ctx, @@ -86,9 +92,8 @@ func main() { // join the chat // Same as above - //chat, err := NewChat(wakuNode, wakuNode.Host().ID(), *contentTopicFlag, *payloadV1Flag, nick) // TODO Replace wakuNode - chat, err := NewChat("go-nwaku-test", *contentTopicFlag, *payloadV1Flag, nick) + chat, err := NewChat(client, "go-nwaku-test", *contentTopicFlag, *payloadV1Flag, nick) if err != nil { panic(err) }