make peer handling of NewRetValMessage optional, as UI handles it fully #304
|
@ -108,7 +108,7 @@ func (cp *cwtchPeer) Init(eventBus event.Manager) {
|
||||||
|
|
||||||
cp.eventBus = eventBus
|
cp.eventBus = eventBus
|
||||||
cp.AutoHandleEvents([]event.Type{event.EncryptedGroupMessage, event.NewMessageFromPeer, event.PeerAcknowledgement,
|
cp.AutoHandleEvents([]event.Type{event.EncryptedGroupMessage, event.NewMessageFromPeer, event.PeerAcknowledgement,
|
||||||
event.PeerError, event.SendMessageToGroupError, event.NewGetValMessageFromPeer, event.NewRetValMessageFromPeer})
|
event.PeerError, event.SendMessageToGroupError, event.NewGetValMessageFromPeer})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AutoHandleEvents sets an event (if able) to be handled by this peer
|
// AutoHandleEvents sets an event (if able) to be handled by this peer
|
||||||
|
@ -568,6 +568,8 @@ func (cp *cwtchPeer) eventHandler() {
|
||||||
cp.eventBus.Publish(resp)
|
cp.eventBus.Publish(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***** Non default but requestable handlable events *****/
|
||||||
|
|
||||||
case event.NewRetValMessageFromPeer:
|
case event.NewRetValMessageFromPeer:
|
||||||
onion := ev.Data[event.RemotePeer]
|
onion := ev.Data[event.RemotePeer]
|
||||||
scope := ev.Data[event.Scope]
|
scope := ev.Data[event.Scope]
|
||||||
|
@ -580,9 +582,6 @@ func (cp *cwtchPeer) eventHandler() {
|
||||||
cp.SetContactAttribute(onion, attr.GetPeerScope(path), val)
|
cp.SetContactAttribute(onion, attr.GetPeerScope(path), val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Non default but requestable handlable events *****/
|
|
||||||
|
|
||||||
case event.NewGroupInvite:
|
case event.NewGroupInvite:
|
||||||
cp.mutex.Lock()
|
cp.mutex.Lock()
|
||||||
cp.Profile.ProcessInvite(ev.Data[event.GroupInvite], ev.Data[event.RemotePeer])
|
cp.Profile.ProcessInvite(ev.Data[event.GroupInvite], ev.Data[event.RemotePeer])
|
||||||
|
|
|
@ -173,17 +173,17 @@ func TestCwtchPeerIntegration(t *testing.T) {
|
||||||
alice := utils.WaitGetPeer(app, "alice")
|
alice := utils.WaitGetPeer(app, "alice")
|
||||||
fmt.Println("Alice created:", alice.GetOnion())
|
fmt.Println("Alice created:", alice.GetOnion())
|
||||||
alice.SetAttribute(attr.GetPublicScope("name"), "Alice")
|
alice.SetAttribute(attr.GetPublicScope("name"), "Alice")
|
||||||
alice.AutoHandleEvents([]event.Type{event.PeerStateChange, event.ServerStateChange, event.NewGroupInvite})
|
alice.AutoHandleEvents([]event.Type{event.PeerStateChange, event.ServerStateChange, event.NewGroupInvite, event.NewRetValMessageFromPeer})
|
||||||
|
|
||||||
bob := utils.WaitGetPeer(app, "bob")
|
bob := utils.WaitGetPeer(app, "bob")
|
||||||
fmt.Println("Bob created:", bob.GetOnion())
|
fmt.Println("Bob created:", bob.GetOnion())
|
||||||
bob.SetAttribute(attr.GetPublicScope("name"), "Bob")
|
bob.SetAttribute(attr.GetPublicScope("name"), "Bob")
|
||||||
bob.AutoHandleEvents([]event.Type{event.PeerStateChange, event.ServerStateChange, event.NewGroupInvite})
|
bob.AutoHandleEvents([]event.Type{event.PeerStateChange, event.ServerStateChange, event.NewGroupInvite, event.NewRetValMessageFromPeer})
|
||||||
|
|
||||||
carol := utils.WaitGetPeer(appClient, "carol")
|
carol := utils.WaitGetPeer(appClient, "carol")
|
||||||
fmt.Println("Carol created:", carol.GetOnion())
|
fmt.Println("Carol created:", carol.GetOnion())
|
||||||
carol.SetAttribute(attr.GetPublicScope("name"), "Carol")
|
carol.SetAttribute(attr.GetPublicScope("name"), "Carol")
|
||||||
carol.AutoHandleEvents([]event.Type{event.PeerStateChange, event.ServerStateChange, event.NewGroupInvite})
|
carol.AutoHandleEvents([]event.Type{event.PeerStateChange, event.ServerStateChange, event.NewGroupInvite, event.NewRetValMessageFromPeer})
|
||||||
|
|
||||||
app.LaunchPeers()
|
app.LaunchPeers()
|
||||||
appClient.LaunchPeers()
|
appClient.LaunchPeers()
|
||||||
|
|
Loading…
Reference in New Issue