You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Documents the new chunking feature for handling large messages,
including rationale, operational details, and configuration steps
for both Unity (C#) and JavaScript environments. Highlights
the importance of synchronized chunk size limits to address
platform-specific message size restrictions like Android WebView.
Copy file name to clipboardExpand all lines: webview_rpc_runtime_library/README.md
+51-4Lines changed: 51 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -168,11 +168,58 @@ Download the latest release from the [WebViewRPC Code Generator repository](http
168
168
-**Mac**: `protoc-gen-webviewrpc`
169
169
-**Linux**: Not provided (requires manual build).
170
170
171
+
## Chunking for Large Messages
172
+
173
+
To handle environments with message size limitations, such as certain Android WebViews where the JavaScript bridge limit is around 1KB, WebView RPC includes a chunking feature. This allows large messages to be split into smaller chunks and reassembled on the receiving end.
174
+
175
+
### How It Works
176
+
177
+
When chunking is enabled, any message exceeding `MaxChunkSize` is automatically divided into smaller parts. Each chunk is sent individually and then reassembled by the receiver. This process is handled transparently by the library.
178
+
179
+
### Configuration
180
+
181
+
Chunking must be enabled and configured on both the C# (Unity) and JavaScript (WebView) sides to work correctly.
182
+
183
+
#### Unity (C#) Configuration
184
+
185
+
In your Unity script, configure the settings before initializing the client or server.
186
+
187
+
```csharp
188
+
usingWebViewRPC;
189
+
// ...
190
+
191
+
voidStart()
192
+
{
193
+
// Enable chunking and set the max chunk size (e.g., 900 bytes)
194
+
WebViewRpcConfiguration.EnableChunking=true;
195
+
WebViewRpcConfiguration.MaxChunkSize=900;
196
+
197
+
// ... initialize your RPC client/server
198
+
}
199
+
```
200
+
201
+
#### JavaScript Configuration
202
+
203
+
Similarly, configure the settings in your JavaScript code.
> Both the C# and JavaScript sides must have the same `MaxChunkSize` for chunking to function reliably. It is recommended to set this value to around 900 bytes to safely stay under the typical 1KB limit on Android.
217
+
171
218
## Quick Start
172
219
173
220
HelloWorld is a simple RPC service that receives a `HelloRequest` message and returns a `HelloResponse` message. In this example, we will implement HelloWorld and verify communication between the Unity client and the WebView client.
174
221
175
-
The HelloWorld service takes a `HelloRequest` and returns a `HelloResponse`. First, let’s look at the example where the C# side acts as the server and the JavaScript side acts as the client.
222
+
The HelloWorld service takes a `HelloRequest` and returns a `HelloResponse`. First, let's look at the example where the C# side acts as the server and the JavaScript side acts as the client.
176
223
177
224
### Defining the protobuf File
178
225
@@ -265,7 +312,7 @@ protoc \
265
312
- The bridge code mediates communication between C# and JavaScript.
266
313
- WebViewRpc is abstracted so it can be used with any WebView library.
267
314
- Implement the bridge code according to your chosen WebView library.
268
-
- Below is an example using Viewplex’s CanvasWebViewPrefab.
315
+
- Below is an example using Viewplex's CanvasWebViewPrefab.
269
316
270
317
```csharp
271
318
usingSystem;
@@ -335,7 +382,7 @@ export class VuplexBridge {
335
382
if (this._isVuplexReady&&window.vuplex) {
336
383
window.vuplex.postMessage(base64Str);
337
384
} else {
338
-
// If vuplex isn’t ready yet, store messages in a queue
385
+
// If vuplex isn't ready yet, store messages in a queue
339
386
this._pendingMessages.push(base64Str);
340
387
}
341
388
}
@@ -379,7 +426,7 @@ public class WebViewRpcTester : MonoBehaviour
Copy file name to clipboardExpand all lines: webview_rpc_runtime_library/README_ko.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -146,6 +146,54 @@ protoc --version # Ensure compiler version is 3+
146
146
- Linux: 제공하지 않습니다.(직접 빌드 필요)
147
147
148
148
149
+
## 대용량 메시지를 위한 청킹(분할 전송) 기능
150
+
151
+
특정 안드로이드 WebView와 같이 JavaScript 브리지 통신에 약 1KB의 메시지 크기 제한이 있는 환경에 대응하기 위해, WebView RPC는 청킹(Chunking) 기능을 포함하고 있습니다. 이 기능을 사용하면 대용량 메시지를 작은 조각으로 나누어 전송하고 수신 측에서 재조립할 수 있습니다.
152
+
153
+
### 동작 방식
154
+
155
+
청킹이 활성화되면, `MaxChunkSize`를 초과하는 모든 메시지는 자동으로 더 작은 부분으로 분할됩니다. 각 청크는 개별적으로 전송된 후 수신자에 의해 재조립됩니다. 이 과정은 라이브러리 내부에서 투명하게 처리됩니다.
156
+
157
+
### 설정 방법
158
+
159
+
청킹 기능이 올바르게 동작하려면 C#(Unity)와 JavaScript(웹뷰) 양쪽 모두에서 활성화하고 설정해야 합니다.
0 commit comments