update docs
This commit is contained in:
32
README.md
32
README.md
@@ -264,8 +264,8 @@ const { smartpack, smartunpack, plikOneshotUpload, fetchWithBackoff } = msghandl
|
||||
const payload1 = ["test_message", "Hello World", "text"];
|
||||
const payload2 = ["config_data", { key: "value" }, "dictionary"];
|
||||
const payload3 = ["table_data", [{id: 1, name: "Alice"}], "jsontable"];
|
||||
const image_bytes = new Uint8Array([1, 2, 3, ...]); // Image data
|
||||
const payload4 = ["user_avatar", image_bytes, "image"];
|
||||
const file_data = fs.readFileSync('./test/large_image.png'); // Read image from file
|
||||
const payload4 = ["user_avatar", file_data, "binary"];
|
||||
|
||||
const payloads = [payload1, payload2, payload3, payload4]; // Array of arrays
|
||||
|
||||
@@ -524,10 +524,10 @@ Send image data directly in messages:
|
||||
using msghandler
|
||||
|
||||
# Read image file
|
||||
image_path = "./path/to/image.jpg"
|
||||
image_path = "./test/large_image.png"
|
||||
image_data = read(image_path)
|
||||
|
||||
data = [("user_avatar", image_data, "image")]
|
||||
data = [("user_avatar", image_data, "binary")]
|
||||
env, env_json_str = smartpack("/chat/room1", data; fileserver_url="http://localhost:8080")
|
||||
```
|
||||
|
||||
@@ -536,14 +536,32 @@ env, env_json_str = smartpack("/chat/room1", data; fileserver_url="http://localh
|
||||
Send image data directly in messages:
|
||||
|
||||
```javascript
|
||||
const image_data = new Uint8Array([1, 2, 3, ...]); // Image bytes
|
||||
import fs from 'fs';
|
||||
|
||||
const file_data = fs.readFileSync('./test/large_image.png');
|
||||
|
||||
const [envelope, envelopeJsonStr] = await msghandlerCSR.smartpack("/chat/room1", [
|
||||
["user_avatar", image_data, "image"]
|
||||
["user_avatar", file_data, "binary"]
|
||||
]);
|
||||
```
|
||||
|
||||
### Example 6: Request-Response Pattern
|
||||
### Example 6: Table Data (JavaScript)
|
||||
|
||||
For JavaScript frontend, use `jsontable` for tabular data:
|
||||
|
||||
```javascript
|
||||
const tableData = [
|
||||
{ id: 1, name: "Alice", score: 95 },
|
||||
{ id: 2, name: "Bob", score: 88 },
|
||||
{ id: 3, name: "Charlie", score: 92 }
|
||||
];
|
||||
|
||||
const [envelope, envelopeJsonStr] = await msghandlerCSR.smartpack("/data/analysis", [
|
||||
["students", tableData, "jsontable"]
|
||||
]);
|
||||
```
|
||||
|
||||
### Example 7: Request-Response Pattern
|
||||
|
||||
Bi-directional communication with reply-to support.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user