Official cwtch.im peer and server implementations. https://cwtch.im
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bob.go 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package main
  2. import (
  3. "cwtch.im/cwtch/event"
  4. "cwtch.im/cwtch/peer"
  5. "git.openprivacy.ca/openprivacy/libricochet-go/connectivity"
  6. "git.openprivacy.ca/openprivacy/libricochet-go/log"
  7. "os"
  8. "path"
  9. "time"
  10. )
  11. func main() {
  12. // System Boilerplate, We need Tor Up and Running
  13. log.AddEverythingFromPattern("peer/bob")
  14. log.SetLevel(log.LevelDebug)
  15. acn, err := connectivity.StartTor(path.Join(".", ".cwtch"), "")
  16. if err != nil {
  17. log.Errorf("\nError connecting to Tor: %v\n", err)
  18. os.Exit(1)
  19. }
  20. // Set up the Event Buss and Initialize the Peer
  21. eventBus := event.NewEventManager()
  22. bob := peer.NewCwtchPeer("bob")
  23. bob.Init(acn, eventBus)
  24. // Add Alice's Onion Here (It changes run to run)
  25. bob.PeerWithOnion("upiztu7myymjf2dn4x4czhagp7axlnqjvf5zwfegbhtpkqb6v3vgu5yd")
  26. // Send the Message...
  27. log.Infof("Waiting for Bob to Connect to Alice...")
  28. bob.SendMessageToPeer("upiztu7myymjf2dn4x4czhagp7axlnqjvf5zwfegbhtpkqb6v3vgu5yd", "Hello Alice!!!")
  29. // Wait a while...
  30. // Everything is run in a goroutine so the main thread has to stay active
  31. time.Sleep(time.Second * 100)
  32. }