cwtch/app/peer/bob/bob.go

28 lines
558 B
Go
Raw Normal View History

2018-10-04 19:15:03 +00:00
package main
import (
"cwtch.im/cwtch/peer"
"log"
"strconv"
"time"
)
func main() {
2018-10-06 03:50:55 +00:00
bob := peer.NewCwtchPeer("bob")
2018-10-04 19:15:03 +00:00
counter := 1
bob.SetPeerDataHandler(func(onion string, data []byte) []byte {
log.Printf("Recieved %s from %v", data, onion)
counter++
return []byte(strconv.Itoa(counter))
})
2018-10-05 03:18:34 +00:00
connection := bob.PeerWithOnion("f4b6thuwmfszsqd3fzqpr45sdem4qoazdlzr2xmnc7fq22qe746hjqqd")
2018-10-04 19:15:03 +00:00
log.Printf("Waiting for Bob to Connect to Alice...")
connection.SendPacket([]byte("Hello Alice!!!"))
// Wait a while...
time.Sleep(time.Second * 100)
}