本文整理匯總了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);