Commit bf5f2cf 1 parent b664b7d commit bf5f2cf Copy full SHA for bf5f2cf
File tree 1 file changed +24
-13
lines changed
1 file changed +24
-13
lines changed Original file line number Diff line number Diff line change 1
1
# selfAddr & selfName
2
2
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
+
3
13
## selfAddr
4
14
5
15
``` js
@@ -20,23 +30,24 @@ window.webxdc.selfAddr
20
30
21
31
- should not have meaning outside the webxdc application.
22
32
23
- For example, a webxdc application can
33
+ ## Example using selfAddr and selfName
24
34
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.
34
37
35
38
``` 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
+ })
37
50
```
38
51
39
- This is the nick or display name for the webxdc user
40
- which can be displayed in the user interface for human recognition.
41
52
42
53
[ `sendUpdate()` ] : ./sendUpdate.html
You can’t perform that action at this time.
0 commit comments