forked from cwtch.im/cwtch
Merge branch 'ebf2019011512' of cwtch.im/cwtch into master
This commit is contained in:
commit
9bf6679572
10
app/app.go
10
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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue