當前位置: 首頁>>代碼示例>>Java>>正文


Java SocketIOTransport.send方法代碼示例

本文整理匯總了Java中com.koushikdutta.async.http.socketio.transport.SocketIOTransport.send方法的典型用法代碼示例。如果您正苦於以下問題:Java SocketIOTransport.send方法的具體用法?Java SocketIOTransport.send怎麽用?Java SocketIOTransport.send使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.koushikdutta.async.http.socketio.transport.SocketIOTransport的用法示例。


在下文中一共展示了SocketIOTransport.send方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setupHeartbeat

import com.koushikdutta.async.http.socketio.transport.SocketIOTransport; //導入方法依賴的package包/類
void setupHeartbeat() {
    Runnable heartbeatRunner = new Runnable() {
        @Override
        public void run() {
            final SocketIOTransport ts = transport;

            if (heartbeat <= 0 || ts == null || !ts.isConnected())
                return;

            ts.send("2:::");
            ts.getServer().postDelayed(this, heartbeat);
        }
    };

    heartbeatRunner.run();
}
 
開發者ID:jacklongway,項目名稱:LiteSDK,代碼行數:17,代碼來源:SocketIOConnection.java

示例2: acknowledge

import com.koushikdutta.async.http.socketio.transport.SocketIOTransport; //導入方法依賴的package包/類
private Acknowledge acknowledge(final String _messageId, final String endpoint) {
    if (TextUtils.isEmpty(_messageId))
        return null;

    final String messageId = _messageId.replaceAll("\\+$", "");

    return new Acknowledge() {
        @Override
        public void acknowledge(JSONArray arguments) {
            String data = "";
            if (arguments != null)
                data += "+" + arguments.toString();
            SocketIOTransport transport = SocketIOConnection.this.transport;
            if (transport == null) {
                final Exception e = new SocketIOException("not connected to server");
                select(endpoint, new SelectCallback() {
                    @Override
                    public void onSelect(SocketIOClient client) {
                        ExceptionCallback callback = client.exceptionCallback;
                        if (callback != null)
                            callback.onException(e);
                    }
                });
                return;
            }
            transport.send(String.format(Locale.ENGLISH, "6:::%s%s", messageId, data));
        }
    };
}
 
開發者ID:jacklongway,項目名稱:LiteSDK,代碼行數:30,代碼來源:SocketIOConnection.java

示例3: disconnect

import com.koushikdutta.async.http.socketio.transport.SocketIOTransport; //導入方法依賴的package包/類
public void disconnect(SocketIOClient client) {
    clients.remove(client);

    // see if we can leave this endpoint completely
    boolean needsEndpointDisconnect = true;
    for (SocketIOClient other: clients) {
        // if this is the default endpoint (which disconnects everything),
        // or another client is using this endpoint,
        // we can't disconnect
        if (TextUtils.equals(other.endpoint, client.endpoint) || TextUtils.isEmpty(client.endpoint)) {
            needsEndpointDisconnect = false;
            break;
        }
    }

    final SocketIOTransport ts = transport;

    if (needsEndpointDisconnect && ts != null)
        ts.send(String.format(Locale.ENGLISH, "0::%s", client.endpoint));

    // and see if we can disconnect the socket completely
    if (clients.size() > 0 || ts == null)
        return;

    ts.setStringCallback(null);
    ts.setClosedCallback(null);
    ts.disconnect();
    transport = null;
}
 
開發者ID:pogointel,項目名稱:openmap-client-android,代碼行數:30,代碼來源:SocketIOConnection.java

示例4: acknowledge

import com.koushikdutta.async.http.socketio.transport.SocketIOTransport; //導入方法依賴的package包/類
private Acknowledge acknowledge(final String _messageId, final String endpoint) {
    if (TextUtils.isEmpty(_messageId))
        return null;

    final String messageId = _messageId.replaceAll("\\+$", "");

    return new Acknowledge() {
        @Override
        public void acknowledge(JSONArray arguments) {
            String data = "";
            if (arguments != null)
                data += "+" + arguments.toString();
            SocketIOTransport transport = SocketIOConnection.this.transport;
            if (transport == null) {
                final Exception e = new SocketIOException("not connected to server");
                select(endpoint, new SelectCallback() {
                    @Override
                    public void onSelect(SocketIOClient client) {
                        ExceptionCallback callback = client.exceptionCallback;
                        if (callback != null)
                            callback.onException(e);
                    }
                });
                return;
            }
            transport.send(String.format("6:::%s%s", messageId, data));
        }
    };
}
 
開發者ID:omerjerk,項目名稱:RemoteDroid,代碼行數:30,代碼來源:SocketIOConnection.java


注:本文中的com.koushikdutta.async.http.socketio.transport.SocketIOTransport.send方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。