当前位置: 首页>>代码示例>>Java>>正文


Java AsyncCallback类代码示例

本文整理汇总了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);
}
 
开发者ID:yukozh,项目名称:CodeComb.Mobile.Android,代码行数:36,代码来源:DisconnectingState.java

示例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");
    }
}
 
开发者ID:TheDeltaProgram,项目名称:iosched2013,代码行数:28,代码来源:ScheduleUpdaterService.java

示例3: getAsyncRequestExecutor

import com.turbomanage.httpclient.AsyncCallback; //导入依赖的package包/类
@Override
public AsyncRequestExecutor getAsyncRequestExecutor(AsyncHttpClient client,
        AsyncCallback callback) {
    return new DoHttpRequestTask(client, callback);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:6,代码来源:AsyncTaskFactory.java

示例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);
}
 
开发者ID:yukozh,项目名称:CodeComb.Mobile.Android,代码行数:70,代码来源:ConnectingState.java

示例5: getAsyncRequestExecutor

import com.turbomanage.httpclient.AsyncCallback; //导入依赖的package包/类
@Override
public AsyncRequestExecutor getAsyncRequestExecutor(AsyncHttpClient client,
        AsyncCallback callback) {
    return new DoParallelHttpRequestTask(client, callback);
}
 
开发者ID:yukozh,项目名称:CodeComb.Mobile.Android,代码行数:6,代码来源:ParallelAsyncTaskFactory.java

示例6: DoParallelHttpRequestTask

import com.turbomanage.httpclient.AsyncCallback; //导入依赖的package包/类
public DoParallelHttpRequestTask(AsyncHttpClient httpClient,
		AsyncCallback callback) {
	super(httpClient, callback);
	// TODO Auto-generated constructor stub
}
 
开发者ID:yukozh,项目名称:CodeComb.Mobile.Android,代码行数:6,代码来源:DoParallelHttpRequestTask.java

示例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;
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:11,代码来源:DoHttpRequestTask.java


注:本文中的com.turbomanage.httpclient.AsyncCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。