cwtch/app/peer/bob/bob.go

29 lines
644 B
Go
Raw Normal View History

2018-10-04 19:15:03 +00:00
package main
import (
"cwtch.im/cwtch/peer"
2018-12-04 02:52:11 +00:00
"git.openprivacy.ca/openprivacy/libricochet-go/log"
2018-10-04 19:15:03 +00:00
"strconv"
"time"
)
func main() {
2018-12-04 02:52:11 +00:00
log.AddEverythingFromPattern("peer/bob")
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 {
2018-12-04 02:52:11 +00:00
log.Infof("Recieved %s from %v", data, onion)
2018-10-04 19:15:03 +00:00
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
2018-12-04 02:52:11 +00:00
log.Infof("Waiting for Bob to Connect to Alice...")
2018-10-04 19:15:03 +00:00
connection.SendPacket([]byte("Hello Alice!!!"))
// Wait a while...
time.Sleep(time.Second * 100)
}