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


Java WebSocket.send方法代码示例

本文整理汇总了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;
}
 
开发者ID:amartinz,项目名称:DeviceControl,代码行数:21,代码来源:ServerWrapper.java

示例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);
    }
}
 
开发者ID:SecUSo,项目名称:privacy-friendly-werewolf,代码行数:15,代码来源:WebSocketServerHandler.java

示例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);
  }
}
 
开发者ID:blad,项目名称:reactive-exchange,代码行数:11,代码来源:CoinbaseWebsocket.java

示例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);
    }
}
 
开发者ID:amartinz,项目名称:DeviceControl,代码行数:10,代码来源:ServerWrapper.java

示例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));
		}
	};
}
 
开发者ID:xiaoshutong,项目名称:AndroidNio,代码行数:30,代码来源:SocketIOConnection.java

示例6: websocketSend

import com.koushikdutta.async.http.WebSocket; //导入方法依赖的package包/类
public static void websocketSend(String message) {
    for (WebSocket socket : webSockets) {
        socket.send(message);
    }
}
 
开发者ID:delletenebre,项目名称:SerialManager,代码行数:6,代码来源:ConnectionService.java


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