|
| 1 | +# tinySSB Simple Chat |
| 2 | + |
| 3 | +SimpleChat is a text-user-interface app for reading and writing public |
| 4 | +chat messages in tinySSB. It serves mostly as a testing tool. |
| 5 | + |
| 6 | +The main program is ```simplechat.py```. It is built on top of |
| 7 | +SimplePub, hence shares several configuration options with |
| 8 | +it. Internal logging messages can be seen by toggeling with ESC the |
| 9 | +screen between the chat and log view. |
| 10 | + |
| 11 | +In comparison to SimplePub, SimpleChat has a notion of authorship. If |
| 12 | +not existing, an ED25519 private key is generated and the corresponding |
| 13 | +append-only log is added to the repository of the unterlying |
| 14 | +SimplePub. Authorship permits to create and sign new log entries, |
| 15 | +which SimplChat requires in order to post messages. |
| 16 | + |
| 17 | +## Description |
| 18 | + |
| 19 | +"tinySSB simple chat" displays all public 'Text-And-Voice' messages found in |
| 20 | +a repo's content; new messages can be added. The replication logic running underneath SimpleChat: |
| 21 | +- is accessible via web sockets, and |
| 22 | +- is accessible via BLE (central-only) |
| 23 | +- runs the tinySSB synchronization protocol |
| 24 | + - datagram-based, packets have 120 Bytes or less |
| 25 | + - growOnlySet protocol for compressing feed IDs |
| 26 | + - vectors with WANT and CHNK information |
| 27 | +- has adaptive timers, made for reliable connections |
| 28 | +- is crash resistant: the ```frontier.bin``` file for a log is updated on startup, should the log have been extended but the frontier failed to be updated |
| 29 | + |
| 30 | +See the README.md of SimplePub for the limitation. |
| 31 | + |
| 32 | +A log entry for the ```TAV``` public chat of tinySSB has the following |
| 33 | +format: |
| 34 | + |
| 35 | +``` |
| 36 | +[ "TAV", # identifies the app |
| 37 | + "a text string", # the posted text |
| 38 | + #c0dec2010..#, # codec2-encoded voice, or null |
| 39 | + 1691098012 ] # timestamp |
| 40 | +``` |
| 41 | + |
| 42 | +This list of four values is BIPF-encoded and stored in the tinySSB |
| 43 | +append-only log as a "chain20" log entry type. |
| 44 | + |
| 45 | + |
| 46 | +## ```simplechat.py``` - a p2p tinySSB chat client |
| 47 | + |
| 48 | +``` |
| 49 | +usage: simplechat.py [-h] [-data DATAPATH] [-id IDPATH] [-role {in,inout,out}] [-v] [uri_or_port] |
| 50 | +
|
| 51 | +positional arguments: |
| 52 | + uri_or_port TCP port if responder, URI if intiator (default is ws://127.0.0.1:8080) |
| 53 | +
|
| 54 | +options: |
| 55 | + -h, --help show this help message and exit |
| 56 | + -ble enable Bluetooth Low Energ (default: off) |
| 57 | + -data DATAPATH path to persistency directory (default: ./data) |
| 58 | + -id IDPATH path to tinySSB private directory (default: ~/.tinySSB) |
| 59 | + -role {in,inout,out} direction of data flow (default: inout) |
| 60 | + -v print i/o timestamps |
| 61 | +``` |
| 62 | + |
| 63 | +Example how Alice and Bob start their chat clients (on the same machine): |
| 64 | +``` |
| 65 | +% ./simplechat.py -d ./alice -i ./alice -v 8080 # Alice' clients will respond on websocket port 8080 |
| 66 | +
|
| 67 | +% ./simplechat.py -d ./bob -i ./bob -v ws://127.0.0.1:8080 # Bob is initiator |
| 68 | +``` |
| 69 | + |
| 70 | +## Screenshots |
| 71 | + |
| 72 | +The screen of Bob, before sending the reply: |
| 73 | +``` |
| 74 | +-────────── tinyS─────-- <w> connection up─┐ |
| 75 | +│ │ |
| 76 | +│ #19 [TVUK3-ZVR4B] │ |
| 77 | +│ Heyo local butts, what's going on! │ |
| 78 | +│ _ ⏲ 2023-06-24 19:48:45 │ |
| 79 | +│ │ |
| 80 | +│ #20 [6F24K-PBSQ6] │ |
| 81 | +│ <voice msg> │ |
| 82 | +│ _ ⏲ 2023-06-26 01:10:18 │ |
| 83 | +│ │ |
| 84 | +│ #21 [73ZOO-QOWFW] │ |
| 85 | +│ Message │ |
| 86 | +│ _ ⏲ 2023-07-04 07:50:33 │ |
| 87 | +│ │ |
| 88 | +│ #22 [QDS2Z-Z3U6W] │ |
| 89 | +│ Message │ |
| 90 | +│ _ ⏲ 2023-07-04 08:02:44 │ |
| 91 | +│ │ |
| 92 | +│ #23 [7NQQX-YZUDL] │ |
| 93 | +│ Hi Bob, how are you? Cheers, Alice │ |
| 94 | +│ _ ⏲ 2023-08-03 23:22:45 │ |
| 95 | +│ │ |
| 96 | +┌────────────────────────────────────./bob─┐ |
| 97 | +│> Hi Alice, all is fine. Best, Bob │ |
| 98 | +└─────────────────── ESC=log/chat ^C=exit ─┘ |
| 99 | +``` |
| 100 | + |
| 101 | +The screen of Alice, after having received the reply: |
| 102 | +``` |
| 103 | +/────────── tinyS─────────────sending 120B─┐ |
| 104 | +│ │ |
| 105 | +│ #20 [6F24K-PBSQ6] │ |
| 106 | +│ <voice msg> │ |
| 107 | +│ _ ⏲ 2023-06-26 01:10:18 │ |
| 108 | +│ │ |
| 109 | +│ #21 [73ZOO-QOWFW] │ |
| 110 | +│ Message │ |
| 111 | +│ _ ⏲ 2023-07-04 07:50:33 │ |
| 112 | +│ │ |
| 113 | +│ #22 [QDS2Z-Z3U6W] │ |
| 114 | +│ Message │ |
| 115 | +│ _ ⏲ 2023-07-04 08:02:44 │ |
| 116 | +│ │ |
| 117 | +│ #23 [7NQQX-YZUDL] │ |
| 118 | +│ Hi Bob, how are you? Cheers, Alice │ |
| 119 | +│ _ ⏲ 2023-08-03 23:22:45 │ |
| 120 | +│ │ |
| 121 | +│ #24 [LJUGR-FULBS] │ |
| 122 | +│ Hi Alice, all is fine. Best, Bob │ |
| 123 | +│ _ ⏲ 2023-08-03 23:26:52 │ |
| 124 | +│ │ |
| 125 | +┌──────────────────────────────────./alice─┐ |
| 126 | +│> │ |
| 127 | +└─────────────────── ESC=log/chat ^C=exit ─┘ |
| 128 | +``` |
| 129 | + |
| 130 | + |
| 131 | +Showing the log view (switching is done with ESC) |
| 132 | +``` |
| 133 | +-────^[──── tinyS─────-- <w> connection up─┐ |
| 134 | +│ │ |
| 135 | +│ gset dmx 613dfa70c47aba │ |
| 136 | +│ want dmx 343fc019f3c9ad │ |
| 137 | +│ chnk dmx 2af30fda04c000 │ |
| 138 | +│ Starting websocket responder on port 808 │ |
| 139 | +│ w> 0.000 o=1 61B 0x343fc019f3c9ada40│ |
| 140 | +│ <w 0.001 i=2 22B 0x2af30fda04c000743│ |
| 141 | +│ <w 0.001 i=3 105B 0x613dfa70c47aba631│ |
| 142 | +│ w> 4.002 o=4 61B 0x343fc019f3c9ada40│ |
| 143 | +│ <w 4.003 i=5 22B 0x2af30fda04c000743│ |
| 144 | +│ new c=[ 1.6.32 1.7.0 ] │ |
| 145 | +│ w> 8.004 o=6 61B 0x343fc019f3c9ada40│ |
| 146 | +│ <w 8.007 i=7 22B 0x2af30fda04c000743│ |
| 147 | +│ new c=[ 1.6.32 1.7.0 ] │ |
| 148 | +│ w> 12.006 o=8 61B 0x343fc019f3c9ada4│ |
| 149 | +│ <w 12.007 i=9 22B 0x2af30fda04c00074│ |
| 150 | +│ <w 15.002 i=10 105B 0x613dfa70c47aba63│ |
| 151 | +│ w> 16.008 o=11 61B 0x343fc019f3c9ada4│ |
| 152 | +│ <w 16.010 i=12 22B 0x2af30fda04c00074│ |
| 153 | +│ new c=[ 1.6.32 1.7.0 ] │ |
| 154 | +│ =C [ 1.6.32 1.7.0 ] [] │ |
| 155 | +┌──────────────────────────────────./alice─┐ |
| 156 | +│> │ |
| 157 | +└─────────────────── ESC=log/chat ^C=exit ─┘ |
| 158 | +``` |
| 159 | + |
| 160 | +--- |
0 commit comments