Adding a Contact #115

Open
opened 2023-02-08 00:43:57 +00:00 by psyc · 1 comment

Sorry if this is a stupid question but I am wondering how to add a contact and send a message to them using the library...
The process should be something like this but I don't see a function for it:

// assuming a profile is created already
c_StartCwtch()
check if c_Started() = 1
watch c_GetAppBusEvent()
wait for ACNStatus = Done
c_ActivatePeerEngine()
<-- add contact so peer can accept message
c_SendMessage()

Sorry if this is a stupid question but I am wondering how to add a contact and send a message to them using the library... The process should be something like this but I don't see a function for it: ``` // assuming a profile is created already c_StartCwtch() check if c_Started() = 1 watch c_GetAppBusEvent() wait for ACNStatus = Done c_ActivatePeerEngine() <-- add contact so peer can accept message c_SendMessage() ```
Owner

This is definitely non-obvious because this library is a shim between Cwtch and a UI, so it has some idiosyncratic assumptions bout how clients interact with it that we hide away in the higher level rust/go libraries.

Background - with some exceptions the UI is asynchronous so it is necessary to listen to the event bus messages to manage state (see: https://git.openprivacy.ca/cwtch.im/cwtch-ui/src/branch/trunk/lib/cwtch/cwtchNotifier.dart#L59 for an example)

Adding a Contact

This can be done using the c_ImportBundle where the "bundle" is a cwtch onion address. See: https://git.openprivacy.ca/cwtch.im/libcwtch-go/src/branch/trunk/lib.go#L1105

This will trigger a ContactCreated event on the event bus which will contain the conversation id needed to send a message.

(https://git.openprivacy.ca/cwtch.im/libcwtch-go/src/branch/trunk/utils/eventHandler.go#L433)

(On startup this information is currently available via the NewPeer message which has a list of known contacts).

Also worth noting that there is an open issue which will likely change this behavior in the future: cwtch.im/cwtch-ui#403

Another note. If there is no need to use c-bindings then are direct APIs available in CwtchPeer for theses purpose: https://git.openprivacy.ca/cwtch.im/cwtch/src/branch/master/peer/profile_interface.go#L106 - though we are currently working on exposing these as part of the bindings API (per: https://docs.cwtch.im/blog/cwtch-stable-api-design)

Hope that helps - feel free to ask followups.

This is definitely non-obvious because this library is a shim between Cwtch and a UI, so it has some idiosyncratic assumptions bout how clients interact with it that we hide away in the higher level rust/go libraries. **Background** - with some exceptions the UI is asynchronous so it is necessary to listen to the event bus messages to manage state (see: https://git.openprivacy.ca/cwtch.im/cwtch-ui/src/branch/trunk/lib/cwtch/cwtchNotifier.dart#L59 for an example) #### Adding a Contact This can be done using the `c_ImportBundle` where the "bundle" is a cwtch onion address. See: https://git.openprivacy.ca/cwtch.im/libcwtch-go/src/branch/trunk/lib.go#L1105 This will trigger a `ContactCreated` event on the event bus which will contain the conversation id needed to send a message. (https://git.openprivacy.ca/cwtch.im/libcwtch-go/src/branch/trunk/utils/eventHandler.go#L433) (On startup this information is currently available via the `NewPeer` message which has a list of known contacts). Also worth noting that there is an open issue which will likely change this behavior in the future: https://git.openprivacy.ca/cwtch.im/cwtch-ui/issues/403 Another note. If there is no need to use c-bindings then are direct APIs available in CwtchPeer for theses purpose: https://git.openprivacy.ca/cwtch.im/cwtch/src/branch/master/peer/profile_interface.go#L106 - though we are currently working on exposing these as part of the bindings API (per: https://docs.cwtch.im/blog/cwtch-stable-api-design) Hope that helps - feel free to ask followups.
This repo is archived. You cannot comment on issues.
No Label
No Milestone
No Assignees
2 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cwtch.im/libcwtch-go#115
No description provided.