WebRTCClient class
WebRTCClient - 通过 WebRTC DataChannel 实现 HTTP 语义的客户端
使用流程:
- 创建 WebRTCClient 实例
- 设置 WebrtcConnection(连接建立后)
- 调用 get/post 方法发送请求
示例:
final client = WebRTCClient();
client.setConnection(connection, '192.168.1.1', 8080);
// 发送 GET 请求
final response = await client.get('/api/files/list', {'path': '/home'}, null);
// 发送 POST 请求
final response = await client.post('/api/files/upload', {'name': 'test.txt'}, null);
- Implemented types
Constructors
- WebRTCClient({int timeoutMs = defaultTimeoutMs})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isConnected → bool
-
检查连接是否可用
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- timeoutMs ↔ int
-
请求超时时间(毫秒)
getter/setter pair
Methods
-
delete(
String url, Map< String, dynamic> ? bodyParams, Map<String, dynamic> ? headers) → Future - 发送 DELETE 请求
-
dispose(
) → void - 释放资源
-
get(
String url, Map< String, dynamic> ? bodyParams, Map<String, dynamic> ? headers) → Future -
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
post(
String url, Map< String, dynamic> ? bodyParams, Map<String, dynamic> ? headers) → Future -
override
-
put(
String url, Map< String, dynamic> ? bodyParams, Map<String, dynamic> ? headers) → Future - 发送 PUT 请求
-
setConnection(
WebrtcConnection connection, String host, int port) → void - 设置 WebRTC 连接和目标地址
-
toString(
) → String -
A string representation of this object.
inherited
-
waitForConnection(
{int timeoutMs = 10000}) → Future< bool> - 等待连接就绪
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- defaultTimeoutMs → const int
- 默认超时时间(毫秒)