cwtch/app/peer/alice/alice.go

39 行
1023 B
Go

2018-10-04 19:15:03 +00:00
package main
import (
app2 "cwtch.im/cwtch/app"
"cwtch.im/cwtch/app/utils"
2019-01-04 21:44:21 +00:00
"cwtch.im/cwtch/event"
"git.openprivacy.ca/openprivacy/libricochet-go/connectivity"
2018-12-04 02:52:11 +00:00
"git.openprivacy.ca/openprivacy/libricochet-go/log"
2019-01-04 21:44:21 +00:00
"os"
"path"
2018-10-04 19:15:03 +00:00
)
func main() {
2019-01-04 21:44:21 +00:00
// System Setup, We need Tor and Logging up and Running
2018-12-04 02:52:11 +00:00
log.AddEverythingFromPattern("peer/alice")
2019-01-04 21:44:21 +00:00
log.SetLevel(log.LevelDebug)
2018-10-04 19:15:03 +00:00
2019-01-04 21:44:21 +00:00
acn, err := connectivity.StartTor(path.Join(".", ".cwtch"), "")
if err != nil {
log.Errorf("\nError connecting to Tor: %v\n", err)
os.Exit(1)
2018-10-04 19:15:03 +00:00
}
app := app2.NewApp(acn, ".")
app.CreatePeer("alice", "be gay, do crimes")
alice := utils.WaitGetPeer(app, "alice")
app.LaunchPeers()
eventBus := app.GetEventBus(alice.GetProfile().Onion)
queue := event.NewQueue()
eventBus.Subscribe(event.NewMessageFromPeer, queue)
2019-01-04 21:44:21 +00:00
2019-01-28 20:09:25 +00:00
// For every new Data Packet Alice received she will Print it out.
2019-01-04 21:44:21 +00:00
for {
event := queue.Next()
log.Printf(log.LevelInfo, "Received %v from %v: %s", event.EventType, event.Data["Onion"], event.Data["Data"])
}
2018-10-04 19:15:03 +00:00
}