本文整理汇总了Java中com.turbomanage.httpclient.AsyncCallback类的典型用法代码示例。如果您正苦于以下问题:Java AsyncCallback类的具体用法?Java AsyncCallback怎么用?Java AsyncCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AsyncCallback类属于com.turbomanage.httpclient包,在下文中一共展示了AsyncCallback类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: OnRun
import com.turbomanage.httpclient.AsyncCallback; //导入依赖的package包/类
@Override
protected void OnRun() {
String url = SignalAUtils.EnsureEndsWith(mConnection.getUrl(), "/");
try {
url += "abort?transport=LongPolling&connectionToken=" + URLEncoder.encode(mConnection.getConnectionToken(), "utf-8");
} catch (UnsupportedEncodingException e) {
Log.e(TAG, "Unsupported message encoding error, when encoding connectionToken.");
}
TransportHelper.AppendCustomQueryString(mConnection, url);
AsyncCallback cb = new AsyncCallback() {
@Override
public void onComplete(HttpResponse httpResponse) {
if(httpResponse.getStatus() != 200 || httpResponse.getBodyAsString() == null || httpResponse.getBodyAsString().isEmpty())
{
Log.e(TAG, "Clean disconnect failed. " + httpResponse.getStatus());
}
mConnection.SetNewState(new DisconnectedState(mConnection));
}
@Override
public void onError(Exception ex) {
mConnection.setError(ex);
mConnection.SetNewState(new DisconnectedState(mConnection));
}
};
ParallelHttpClient httpClient = new ParallelHttpClient();
httpClient.setMaxRetries(1);
ParameterMap params = httpClient.newParams();
httpClient.post(url, params, cb);
}
示例2: notifyGcmDevices
import com.turbomanage.httpclient.AsyncCallback; //导入依赖的package包/类
private void notifyGcmDevices() {
String plusID = AccountUtils.getPlusProfileId(getApplicationContext());
if (plusID != null) {
LOGI(TAG, "Sending device sync notification");
AndroidHttpClient httpClient = new AndroidHttpClient(Config.GCM_SERVER_URL);
httpClient.setMaxRetries(1);
ParameterMap params = httpClient.newParams()
.add("key", Config.GCM_API_KEY)
.add("squelch", ServerUtilities.getGcmId(this));
String path = "/send/" + plusID + "/sync_user";
httpClient.post(path, params, new AsyncCallback() {
@Override
public void onComplete(HttpResponse httpResponse) {
LOGI(TAG, "Device sync notification sent");
}
@Override
public void onError(Exception e) {
LOGW(TAG, "Device sync notification failed", e);
}
});
} else {
LOGI(TAG, "No gPlusID, skipping device sync notification");
}
}
示例3: getAsyncRequestExecutor
import com.turbomanage.httpclient.AsyncCallback; //导入依赖的package包/类
@Override
public AsyncRequestExecutor getAsyncRequestExecutor(AsyncHttpClient client,
AsyncCallback callback) {
return new DoHttpRequestTask(client, callback);
}
示例4: OnRun
import com.turbomanage.httpclient.AsyncCallback; //导入依赖的package包/类
@Override
protected void OnRun() {
if(DoStop()) return;
// negotiate
String url = SignalAUtils.EnsureEndsWith(mConnection.getUrl(), "/") + "negotiate";
TransportHelper.AppendCustomQueryString(mConnection, url);
AsyncCallback cb = new AsyncCallback() {
@Override
public void onComplete(HttpResponse httpResponse) {
try
{
if(DoStop()) return;
if(httpResponse!=null && httpResponse.getStatus()==200 && !httpResponse.getBodyAsString().equals(""))
{
JSONObject json = JSONHelper.ToJSONObject(httpResponse.getBodyAsString());
String connectionId="";
String connectionToken="";
String protocolVersion = "";
try {
connectionId = json.getString("ConnectionId");
connectionToken = json.getString("ConnectionToken");
protocolVersion = json.getString("ProtocolVersion");
if(mConnection.VerifyProtocolVersion(protocolVersion))
{
mConnection.setConnectionId(connectionId);
mConnection.setConnectionToken(connectionToken);
mConnection.SetNewState(new ConnectedState(mConnection));
return;
}
else
{
mConnection.setError(new Exception("Not supported protocol version."));
mConnection.SetNewState(new DisconnectedState(mConnection));
return;
}
} catch (JSONException e) {
mConnection.setError(new Exception("Unable to parse negotiation response."));
return;
}
}
else
{
mConnection.SetNewState(new DisconnectedState(mConnection));
}
}
finally
{
mIsRunning.set(false);
}
}
@Override
public void onError(Exception ex) {
mConnection.setError(ex);
mConnection.SetNewState(new DisconnectedState(mConnection));
}
};
synchronized (mCallbackLock) {
//mCurrentCallback = cb;
}
ParallelHttpClient httpClient = new ParallelHttpClient();
httpClient.setMaxRetries(1);
httpClient.get(url, null, cb);
}
示例5: getAsyncRequestExecutor
import com.turbomanage.httpclient.AsyncCallback; //导入依赖的package包/类
@Override
public AsyncRequestExecutor getAsyncRequestExecutor(AsyncHttpClient client,
AsyncCallback callback) {
return new DoParallelHttpRequestTask(client, callback);
}
示例6: DoParallelHttpRequestTask
import com.turbomanage.httpclient.AsyncCallback; //导入依赖的package包/类
public DoParallelHttpRequestTask(AsyncHttpClient httpClient,
AsyncCallback callback) {
super(httpClient, callback);
// TODO Auto-generated constructor stub
}
示例7: DoHttpRequestTask
import com.turbomanage.httpclient.AsyncCallback; //导入依赖的package包/类
/**
* Construct a new task with a callback to invoke when the request completes
* or fails.
*
* @param callback
*/
public DoHttpRequestTask(AsyncHttpClient httpClient, AsyncCallback callback) {
this.client = httpClient;
this.callback = callback;
}