diff --git a/app/app.go b/app/app.go index d10ae9b..d79653d 100644 --- a/app/app.go +++ b/app/app.go @@ -24,7 +24,7 @@ type application struct { mutex sync.Mutex primaryonion string storage map[string]storage.ProfileStore - eventBus *event.Manager + EventBus *event.Manager } // Application is a full cwtch peer application. It allows management, usage and storage of multiple peers @@ -48,8 +48,8 @@ func NewApp(acn connectivity.ACN, appDirectory string) Application { log.Debugf("NewApp(%v)\n", appDirectory) app := &application{peers: make(map[string]peer.CwtchPeer), storage: make(map[string]storage.ProfileStore), directory: appDirectory, acn: acn} os.Mkdir(path.Join(app.directory, "profiles"), 0700) - app.eventBus = new(event.Manager) - app.eventBus.Initialize() + app.EventBus = new(event.Manager) + app.EventBus.Initialize() return app } @@ -77,7 +77,7 @@ func (app *application) CreatePeer(name string, password string) (peer.CwtchPeer if err != nil { return nil, err } - p.Init(app.acn, app.eventBus) + p.Init(app.acn, app.EventBus) _, exists := app.peers[p.GetProfile().Onion] if exists { p.Shutdown() @@ -113,7 +113,7 @@ func (app *application) LoadProfiles(password string) error { continue } - p.Init(app.acn, app.eventBus) + p.Init(app.acn, app.EventBus) app.mutex.Lock() app.peers[p.GetProfile().Onion] = p diff --git a/peer/cwtch_peer.go b/peer/cwtch_peer.go index cefb95e..f29d0e0 100644 --- a/peer/cwtch_peer.go +++ b/peer/cwtch_peer.go @@ -35,7 +35,7 @@ type CwtchPeer interface { Init(connectivity.ACN, *event.Manager) PeerWithOnion(string) *connections.PeerPeerConnection InviteOnionToGroup(string, string) error - SendMessageToPeer(string, string) + SendMessageToPeer(string, string) string TrustPeer(string) error BlockPeer(string) error @@ -216,8 +216,10 @@ func (cp *cwtchPeer) SendMessageToGroup(groupid string, message string) error { return err } -func (cp *cwtchPeer) SendMessageToPeer(onion string, message string) { - cp.eventBus.Publish(event.NewEvent(event.SendMessageToPeer, map[string]string{"Peer": onion, "Message": message})) +func (cp *cwtchPeer) SendMessageToPeer(onion string, message string) string { + event := event.NewEvent(event.SendMessageToPeer, map[string]string{"Peer": onion, "Message": message}) + cp.eventBus.Publish(event) + return event.EventID } // GetPeers returns a list of peer connections.