28 lines
538 B
Go
28 lines
538 B
Go
|
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)
|
||
|
|
||
|
}
|