Skip to content

Commit bf5f2cf

Browse files
committed
clearer structure, and a combined example
1 parent b664b7d commit bf5f2cf

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed
+24-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# selfAddr & selfName
22

3+
## selfName
4+
5+
```js
6+
window.webxdc.selfName
7+
```
8+
9+
This is the nick or display name for the webxdc user
10+
which can be displayed in the user interface for human recognition.
11+
12+
313
## selfAddr
414

515
```js
@@ -20,23 +30,24 @@ window.webxdc.selfAddr
2030

2131
- should not have meaning outside the webxdc application.
2232

23-
For example, a webxdc application can
33+
## Example using selfAddr and selfName
2434

25-
- send its `selfAddr` value as part of the `payload` passed into [`sendUpdate()`],
26-
27-
- receive such addresses through the payload of incoming updates,
28-
29-
- put such addresses into the `notify` parameter passed to [`sendUpdate()`]
30-
to cause a user-interface notification for respective users.
31-
32-
33-
## selfName
35+
Here is a simple chat app that sends out a reply using the display names
36+
but uses the addresses for notifications.
3437

3538
```js
36-
window.webxdc.selfName
39+
40+
setUpdateListener((update) => {
41+
sendUpdate({
42+
payload: {
43+
senderAddr: webxdc.selfAddr,
44+
senderName: webxdc.selfName,
45+
},
46+
info: "hello ${update.senderName} from ${webxdc.selfName}}",
47+
notify: [update.senderAddr]
48+
})
49+
})
3750
```
3851

39-
This is the nick or display name for the webxdc user
40-
which can be displayed in the user interface for human recognition.
4152

4253
[`sendUpdate()`]: ./sendUpdate.html

0 commit comments

Comments
 (0)