本文整理汇总了Java中com.mpush.api.http.HttpResponse类的典型用法代码示例。如果您正苦于以下问题:Java HttpResponse类的具体用法?Java HttpResponse怎么用?Java HttpResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HttpResponse类属于com.mpush.api.http包,在下文中一共展示了HttpResponse类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendHttpProxy
import com.mpush.api.http.HttpResponse; //导入依赖的package包/类
/**
* 发送Http代理请求
*
* @param request 要代理的http请求
* @return
*/
public Future<HttpResponse> sendHttpProxy(HttpRequest request) {
if (hasStarted() && client.isRunning()) {
return client.sendHttp(request);
}
return null;
}
示例2: handle
import com.mpush.api.http.HttpResponse; //导入依赖的package包/类
@Override
public void handle(HttpResponseMessage message) {
HttpRequestMgr.RequestTask task = httpRequestMgr.getAndRemove(message.getSessionId());
if (task != null) {
HttpResponse response = new HttpResponse(message.statusCode, message.reasonPhrase, message.headers, message.body);
task.setResponse(response);
}
logger.d(">>> receive one response, sessionId=%d, statusCode=%d", message.getSessionId(), message.statusCode);
}
示例3: sendHttp
import com.mpush.api.http.HttpResponse; //导入依赖的package包/类
@Override
public Future<HttpResponse> sendHttp(HttpRequest request) {
if (connection.getSessionContext().handshakeOk()) {
HttpRequestMessage message = new HttpRequestMessage(connection);
message.method = request.getMethod();
message.uri = request.getUri();
message.headers = request.getHeaders();
message.body = request.getBody();
message.send();
logger.d("<<< send http proxy, request=%s", request);
return httpRequestMgr.add(message.getSessionId(), request);
}
return null;
}
示例4: setResponse
import com.mpush.api.http.HttpResponse; //导入依赖的package包/类
public void setResponse(HttpResponse response) {
if (this.future.cancel(true)) {
this.set(response);
if (callback != null) {
callback.onResponse(response);
}
callback = null;
}
logger.d("one request task end, sessionId=%d, costTime=%d, response=%d, uri=%s",
sessionId, (System.currentTimeMillis() - sendTime), response.statusCode, uri);
}
示例5: sendPush
import com.mpush.api.http.HttpResponse; //导入依赖的package包/类
@ReactMethod
public void sendPush(final ReadableMap options, final Promise promise){
if( !MPush.I.hasInit()) {
promise.reject("MPush is not init!");
return;
}
if( !options.hasKey("userId")) {
promise.reject("Params userId is null!");
return;
}
if( !options.hasKey("hello")) {
promise.reject("Params hello is null!");
return;
}
final Activity activity = getCurrentActivity();
if (activity == null) {
promise.reject("Current Activity is null!");
return;
}
JSONObject params = new JSONObject();
try {
params.put("userId", options.getString("userId"));
params.put("hello", options.getString("hello"));
} catch (JSONException e) {
promise.reject("SendPush For Exception: " + e.getMessage());
return;
}
final Context context = getReactApplicationContext();
HttpRequest request = new HttpRequest(HttpMethod.POST, allocServer + "/push");
byte[] body = params.toString().getBytes(Constants.UTF_8);
request.setBody(body, "application/json; charset=utf-8");
request.setTimeout((int) TimeUnit.SECONDS.toMillis(10));
request.setCallback(new HttpCallback() {
@Override
public void onResponse(final HttpResponse httpResponse) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (httpResponse.statusCode == 200) {
promise.resolve(new String(httpResponse.body, Constants.UTF_8));
} else {
promise.reject(httpResponse.reasonPhrase);
}
}
});
}
@Override
public void onCancelled() {
promise.reject("SendPush on cancelled");
}
});
MPush.I.sendHttpProxy(request);
}
示例6: call
import com.mpush.api.http.HttpResponse; //导入依赖的package包/类
@Override
public HttpResponse call() throws Exception {
return response408;
}
示例7: add
import com.mpush.api.http.HttpResponse; //导入依赖的package包/类
public Future<HttpResponse> add(int sessionId, HttpRequest request) {
RequestTask task = new RequestTask(sessionId, request);
queue.put(sessionId, task);
task.future = timer.schedule(task, task.timeout, TimeUnit.MILLISECONDS);
return task;
}
示例8: sendHttp
import com.mpush.api.http.HttpResponse; //导入依赖的package包/类
Future<HttpResponse> sendHttp(HttpRequest request);