连接事件
// 信号法
@HttpRequest.Connect(
HttpRequest.SignalName.RequestCompleted,
Callable.From<long, long, string[], byte[]>(OnRequestCompleted)
)
// C#事件法
@HttpRequest.RequestCompleted += OnRequestCompleted;发送请求
Error @HttpRequest.Request(
string url,
[string[] customHeaders = null],
[HttpClient.Method method = HttpClient.Method.Get],
[string requestData = ""]
)处理请求
void OnRequestCompleted(long result, long responseCode, string[] headers, byte[] body) {
if (result != (long)HttpRequest.Result.Success)
throw new Exception("请求失败");
if (responseCode != 200)
throw new Exception("响应码不正确");
string text = Encoding.UTF8.GetString(body);
// text...
}