Browse Source

make peer handling of NewRetValMessage optional, as UI handles it fully

pull/304/head
Dan Ballard 1 month ago
parent
commit
5f39c1d498
2 changed files with 6 additions and 7 deletions
  1. +3
    -4
      peer/cwtch_peer.go
  2. +3
    -3
      testing/cwtch_peer_server_integration_test.go

+ 3
- 4
peer/cwtch_peer.go View File

@@ -108,7 +108,7 @@ func (cp *cwtchPeer) Init(eventBus event.Manager) {

cp.eventBus = eventBus
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
@@ -568,6 +568,8 @@ func (cp *cwtchPeer) eventHandler() {
cp.eventBus.Publish(resp)
}

/***** Non default but requestable handlable events *****/

case event.NewRetValMessageFromPeer:
onion := ev.Data[event.RemotePeer]
scope := ev.Data[event.Scope]
@@ -580,9 +582,6 @@ func (cp *cwtchPeer) eventHandler() {
cp.SetContactAttribute(onion, attr.GetPeerScope(path), val)
}
}

/***** Non default but requestable handlable events *****/

case event.NewGroupInvite:
cp.mutex.Lock()
cp.Profile.ProcessInvite(ev.Data[event.GroupInvite], ev.Data[event.RemotePeer])


+ 3
- 3
testing/cwtch_peer_server_integration_test.go View File

@@ -173,17 +173,17 @@ func TestCwtchPeerIntegration(t *testing.T) {
alice := utils.WaitGetPeer(app, "alice")
fmt.Println("Alice created:", alice.GetOnion())
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")
fmt.Println("Bob created:", bob.GetOnion())
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")
fmt.Println("Carol created:", carol.GetOnion())
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()
appClient.LaunchPeers()


Loading…
Cancel
Save