From 5f2777cdb2521914dd525c2d20728d98cea1b8a8 Mon Sep 17 00:00:00 2001 From: jasonwitty Date: Tue, 9 Sep 2025 02:53:50 -0700 Subject: [PATCH 1/2] Update README.md --- socktop_wasm_test/README.md | 68 ------------------------------------- 1 file changed, 68 deletions(-) diff --git a/socktop_wasm_test/README.md b/socktop_wasm_test/README.md index a4d1404..0bbe91b 100644 --- a/socktop_wasm_test/README.md +++ b/socktop_wasm_test/README.md @@ -143,71 +143,3 @@ async function run() { run(); ``` - -## Benefits of This Approach - -1. **Type Safety**: All socktop types work identically in WASM -2. **Validation**: Configuration validation happens in Rust -3. **Maintainability**: Share types between native and WASM code -4. **Performance**: Rust types compile to efficient WASM -5. **Future Proof**: Updates to socktop types automatically work in WASM - -## Real-World Usage - -For production WASM applications: - -1. Use this pattern to create a WASM module that exports configuration and serialization functions -2. Handle WebSocket connections in JavaScript using browser APIs -3. Use the exported functions for type-safe message creation and parsing -4. Leverage socktop's structured error handling for robust applications -- **No TLS dependencies**: Completely avoids rustls/TLS -- **No tokio/mio**: Uses only WASM-compatible dependencies - -### ❌ WASM Limitations -- **No native networking**: `tokio-tungstenite` doesn't work in WASM -- **No TLS support**: rustls is not WASM-compatible -- **No file system**: Certificate loading not available - -## Architecture for WASM Users - -``` -WASM Application -├── Use socktop_connector types (✅ this test proves it works) -├── Use browser WebSocket API for networking -└── Handle serialization with socktop message format -``` - -## Quick Start - -1. **Build the WASM package**: - ```bash - cd socktop_wasm_test - wasm-pack build --target web --out-dir pkg - ``` - -2. **Start local server**: - ```bash - basic-http-server . - ``` - -3. **Open browser** to `http://localhost:8000` and click "Run WASM Test" - -## Success Criteria - -- ✅ WASM builds without any networking dependencies -- ✅ Core types compile and serialize properly -- ✅ Configuration API works for WebSocket setup -- ✅ No rustls/TLS/tokio/mio dependencies - -## Real-World WASM Usage - -WASM users should: -1. **Use these types** for message structure compatibility -2. **Use browser WebSocket** for actual connections: - ```javascript - const ws = new WebSocket('ws://localhost:3000/ws'); - ws.send(JSON.stringify({ request: 'Metrics' })); - ``` -3. **Handle responses** using the same serialization format - -This test proves `socktop_connector`'s **types and patterns** work in WASM, even though the networking must be handled differently. From f9367678353bbaa960368a2f0519a5a473e6bcfa Mon Sep 17 00:00:00 2001 From: jasonwitty Date: Tue, 9 Sep 2025 02:57:32 -0700 Subject: [PATCH 2/2] Update README.md --- socktop_wasm_test/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/socktop_wasm_test/README.md b/socktop_wasm_test/README.md index 0bbe91b..0629589 100644 --- a/socktop_wasm_test/README.md +++ b/socktop_wasm_test/README.md @@ -25,6 +25,8 @@ This directory contains a complete WebAssembly (WASM) compatibility test and imp ## Quick Test ```bash +# Please note that the test assumes you have and agent runnign on your local host at port 3000. If you would like to use an alternate configuration please update lib.rs prior to build. + # Build the WASM package wasm-pack build --target web --out-dir pkg