本文整理汇总了Java中com.koushikdutta.async.http.WebSocket.send方法的典型用法代码示例。如果您正苦于以下问题:Java WebSocket.send方法的具体用法?Java WebSocket.send怎么用?Java WebSocket.send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.koushikdutta.async.http.WebSocket
的用法示例。
在下文中一共展示了WebSocket.send方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stopServer
import com.koushikdutta.async.http.WebSocket; //导入方法依赖的package包/类
public void stopServer() {
unregisterReceivers();
if (mServer != null) {
mServer.stop();
mServer = null;
}
if (mServerSocket != null) {
mServerSocket.stop();
mServerSocket = null;
}
for (final WebSocket socket : _sockets) {
if (socket == null) { continue; }
socket.send(ACTION_TERMINATING);
socket.close();
}
_sockets.clear();
isStopped = true;
}
示例2: send
import com.koushikdutta.async.http.WebSocket; //导入方法依赖的package包/类
/**
* Message to send data packages over the network
*
* @param networkPackage
*/
public void send(NetworkPackage networkPackage) {
Gson gson = new Gson();
String s = gson.toJson(networkPackage);
Log.d(TAG, "Server sent package to all clients: " + s);
for (WebSocket socket : _sockets) {
socket.send(s);
}
}
示例3: onCompleted
import com.koushikdutta.async.http.WebSocket; //导入方法依赖的package包/类
@Override public void onCompleted(Exception error, WebSocket webSocket) {
if (error != null) {
for (Subscriber<? super String> subscriber : subscriberList) {
subscriber.onError(error);
}
} else {
webSocket.send(CoinbaseRegistration);
webSocket.setStringCallback(this);
}
}
示例4: onReceive
import com.koushikdutta.async.http.WebSocket; //导入方法依赖的package包/类
@Override public void onReceive(Context context, Intent intent) {
final String level = String.format("batteryLevel|%s", intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 1));
final String charging = String.format("batteryCharging|%s",
intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0 ? "1" : "0");
for (final WebSocket socket : _sockets) {
socket.send(level);
socket.send(charging);
}
}
示例5: acknowledge
import com.koushikdutta.async.http.WebSocket; //导入方法依赖的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();
WebSocket webSocket = SocketIOConnection.this.webSocket;
if (webSocket == null) {
final Exception e = new SocketIOException("websocket is not connected");
select(endpoint, new SelectCallback() {
@Override
public void onSelect(SocketIOClient client) {
ExceptionCallback callback = client.exceptionCallback;
if (callback != null)
callback.onException(e);
}
});
return;
}
webSocket.send(String.format("6:::%s%s", messageId, data));
}
};
}
示例6: websocketSend
import com.koushikdutta.async.http.WebSocket; //导入方法依赖的package包/类
public static void websocketSend(String message) {
for (WebSocket socket : webSockets) {
socket.send(message);
}
}