cwtch/app/peer/bob/bob.go

28 lines
538 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() {
bob, _ := peer.NewCwtchPeer("bob", "password", ".")
counter := 1
bob.SetPeerDataHandler(func(onion string, data []byte) []byte {
log.Printf("Recieved %s from %v", data, onion)
counter++
return []byte(strconv.Itoa(counter))
})
connection := bob.PeerWithOnion("qtpnmnth767gjmpv")
log.Printf("Waiting for Bob to Connect to Alice...")
connection.SendPacket([]byte("Hello Alice!!!"))
// Wait a while...
time.Sleep(time.Second * 100)
}