• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SocketIOClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.corundumstudio.socketio.SocketIOClient的典型用法代码示例。如果您正苦于以下问题:Java SocketIOClient类的具体用法?Java SocketIOClient怎么用?Java SocketIOClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SocketIOClient类属于com.corundumstudio.socketio包,在下文中一共展示了SocketIOClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onData

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
@Override
public void onData(SocketIOClient client, String json, AckRequest ackRequest) throws Exception {
	semaphore.acquire();

	StartScreenBean startScreenBean = JsonUtil.jsonTobean(json, StartScreenBean.class);
	if (startScreenBean == null) {
		logger.error("屏幕请求json出错");
		return;
	}

	String serialNumber = startScreenBean.getSerialNumber();
	ScreenSwitches.startScreen(serialNumber, startScreenBean.getWidth(), startScreenBean.getHeight());
	
	//添加客户端到屏幕中
	if (!ClientCollection.isContainsKey(serialNumber)) {
		ClientCollection.addClients(serialNumber, new TreeSet<UUID>());
	}
	if (!ClientCollection.getUUIDcontainsKey(serialNumber, client.getSessionId())) {
		ClientCollection.addUUID(serialNumber, client.getSessionId());
		logger.info("添加客户端:" + serialNumber + "," + client.getSessionId());
	}
	semaphore.release();// 释放信号量
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:24,代码来源:StartScreenMonitorListener.java


示例2: onData

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
@Override
public void onData(SocketIOClient arg0, String serialNumber, AckRequest arg2)
		throws Exception {
	DeviceEntity deviceEntity = DeviceContainerHandler
			.getDevice(serialNumber);
	if (deviceEntity != null) {
		ApkServiceSocketStream stream = ApkServiceSocketStream
				.getApkStream("ApkServiceSocketStream");
		if (stream.getState().equals(Thread.State.NEW) && !stream.isAlive()) {
			stream.start();
		} else if (!stream.isAlive()
				&& !stream.getState().equals(Thread.State.NEW)) {
			stream.run();
		}

	}
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:18,代码来源:StartServiceListener.java


示例3: onDisconnect

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
@Override
public void onDisconnect(SocketIOClient client) {
	// TODO Auto-generated method stub
	logger.info("websocket客户端下线:"+client.getSessionId()+" IP:"+client.getRemoteAddress());
	
	//从屏幕监听客户端列表中移除下线客户端
	for(String str : ClientCollection.getClientAll()){
		String serialNumber = str;
		List<UUID> removeList=new ArrayList<UUID>();
		for(UUID client_uuid :  ClientCollection.getClients(serialNumber)){
			if(client_uuid.equals(client.getSessionId())&&client_uuid!=null){
				logger.info("从屏幕监听客户端列表中移除:"+client.getSessionId()+" IP:"+client.getRemoteAddress());
				removeList.add(client_uuid);
			}
		}
		if (removeList!=null) {
			for (UUID uuid : removeList) {
				ClientCollection.removeUUID(serialNumber,uuid);
			}
		}
		
	}
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:24,代码来源:ClientDisconnectListener.java


示例4: onData

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
@Override
public void onData(SocketIOClient arg0, String data, AckRequest arg2) throws Exception {
	if (data!=null) {
		List<String> list=JsonUtil.jsonTobean(data=data.trim(), List.class);
		if (list!=null) {
			for (String sernum :list) {
				DeviceEntity deviceEntity=DeviceContainerHandler.getDevice(sernum);
				IDevice idevice=deviceEntity.getIdevice();
				idevice.executeShellCommand(startActivity, receiver);
			}
		}else {
			logger.info("json to bean 失败!!");
		}
	}
	
	
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:18,代码来源:ShowServiceListener.java


示例5: start

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
public static void start() throws InterruptedException {

        Configuration config = new Configuration();
        config.setHostname("localhost");
        config.setPort(9092);

        final SocketIOServer server = new SocketIOServer(config);
        server.addEventListener("chatevent", ChatObject.class, new DataListener<ChatObject>() {
            @Override
            public void onData(SocketIOClient client, ChatObject data, AckRequest ackRequest) {
                server.getBroadcastOperations().sendEvent("chatevent", data);
            }
        });

        server.start();

        Thread.sleep(Integer.MAX_VALUE);

        server.stop();
    }
 
开发者ID:ScreenBasedSimulator,项目名称:ScreenBasedSimulator,代码行数:21,代码来源:EventChatLauncher.java


示例6: start

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
public static void start() throws InterruptedException, UnsupportedEncodingException {

        Configuration config = new Configuration();
        config.setHostname("localhost");
        config.setPort(9092);
        config.setMaxFramePayloadLength(1024 * 1024);
        config.setMaxHttpContentLength(1024 * 1024);

        final SocketIOServer server = new SocketIOServer(config);

        server.addEventListener("msg", byte[].class, new DataListener<byte[]>() {
            @Override
            public void onData(SocketIOClient client, byte[] data, AckRequest ackRequest) {
                client.sendEvent("msg", data);
            }
        });

        server.start();

        Thread.sleep(Integer.MAX_VALUE);

        server.stop();
    }
 
开发者ID:ScreenBasedSimulator,项目名称:ScreenBasedSimulator,代码行数:24,代码来源:BinaryEventLauncher.java


示例7: reportFeedbackForUserInSession

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
public void reportFeedbackForUserInSession(final de.thm.arsnova.entities.Session session, final User user) {
	final de.thm.arsnova.entities.Feedback fb = feedbackService.getBySessionKey(session.getKeyword());
	Long averageFeedback;
	try {
		averageFeedback = feedbackService.calculateRoundedAverageFeedback(session.getKeyword());
	} catch (final NoContentException e) {
		averageFeedback = null;
	}
	final List<UUID> connectionIds = findConnectionIdForUser(user);
	if (connectionIds.isEmpty()) {
		return;
	}

	for (final SocketIOClient client : server.getAllClients()) {
		if (connectionIds.contains(client.getSessionId())) {
			client.sendEvent("feedbackData", fb.getValues());
			client.sendEvent("feedbackDataRoundedAverage", averageFeedback);
		}
	}
}
 
开发者ID:thm-projects,项目名称:arsnova-backend,代码行数:21,代码来源:ArsnovaSocketioServerImpl.java


示例8: onData

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
@Override
public void onData(SocketIOClient client, String data, AckRequest ackSender) throws Exception {
	if (data!=null) {
		TouchEvent event=JsonUtil.jsonTobean(data=data.trim(), TouchEvent.class);
		if (event!=null) {
			EventQueue queue=EventQueue.getinstance();
			queue.addObject(event);
		}else {
			logger.info("json to bean failed!!");
		}
	}
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:13,代码来源:PressedEventListener.java


示例9: onData

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
public void onData(SocketIOClient client, String jsonStr, AckRequest ack)
		throws Exception {
	InstallBean bean = JsonUtil.jsonTobean(jsonStr, InstallBean.class);
	logger.info(jsonStr);
	if(bean != null){
		List<String> serialNumberList = bean.getSerialNumberList();
		String apkPath = bean.getApkPath();
		if(serialNumberList != null && apkPath != null && FileUtil.isFileExist(apkPath)){
			for(String serialNumber : serialNumberList){
				DeviceEntity deviceEntity = DeviceContainerHandler.getDevice(serialNumber);
				if(deviceEntity != null){
					IDevice idevice = deviceEntity.getIdevice();
					if(idevice != null && idevice.isOnline()){
						executorService.execute(new Runnable() {
							@Override
							public void run() {
								SystemWSSender.msg(client,"设备["+deviceEntity.getSerialNumber()+"] 开始安装应用");
								try {
									idevice.installPackage(apkPath, true);
									SystemWSSender.msg(client,"设备["+deviceEntity.getSerialNumber()+"] 应用安装成功");
								} catch (InstallException e) {
									logger.error(serialNumber+":安装apk["+apkPath+"] 出错",e);
									SystemWSSender.error(client,"设备["+serialNumber+"]apk安装出错,原因:"+e.getMessage());
								}
							
							}
						});
					}
				}
			}
		}
	}
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:34,代码来源:InstallListener.java


示例10: onData

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
@Override
public void onData(SocketIOClient client, String data, AckRequest ackSender)
		throws Exception {
	PushBean bean = JsonUtil.jsonTobean(data, PushBean.class);
	if(bean != null){
		List<String> serialNumberList = bean.getSerialNumberList();
		String localPath = bean.getLocalPath();
		String remotePath = bean.getRemotePath();
		if(serialNumberList != null && localPath != null && remotePath != null && FileUtil.isFileExist(localPath)){
			for(String serialNumber : serialNumberList){
				DeviceEntity deviceEntity = DeviceContainerHandler.getDevice(serialNumber);
				if(deviceEntity != null){
					IDevice idevice = deviceEntity.getIdevice();
					if(idevice != null){
						executorService.execute(new Runnable() {
							
							@Override
							public void run() {
								try {
									SystemWSSender.msg(client, "正在发送文件到["+deviceEntity.getSerialNumber()+"]:"+remotePath);
									logger.info(remotePath);
									idevice.pushFile(localPath, remotePath);
									SystemWSSender.msg(client, "文件成功发送到 "+deviceEntity.getSerialNumber());
								} catch (SyncException | IOException
										| AdbCommandRejectedException
										| TimeoutException e) {
									logger.info("文件发送出错",e);
									SystemWSSender.warn("["+deviceEntity.getSerialNumber()+"] 文件发送出错"+e.getMessage());
								}
							}
						});
					}
				}
			}
		}
	}
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:38,代码来源:PushFileListener.java


示例11: onData

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
@Override
public void onData(SocketIOClient client, String data, AckRequest ackSender) throws Exception {
	data=data.trim();
	if (data!=null) {
		ReleasedEvent event=JsonUtil.jsonTobean(data, ReleasedEvent.class);
		if (event!=null) {
			EventQueue queue=EventQueue.getinstance();
			queue.addObject(event);
		}else {
			logger.info("json to bean failed!!");
		}
	}
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:14,代码来源:ReleasedEventListener.java


示例12: onData

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
@Override
public void onData(SocketIOClient client, String data, AckRequest ackSender) throws Exception {
	if (data!=null) {
		TouchDraggedEvent event=JsonUtil.jsonTobean(data.trim(), TouchDraggedEvent.class);
		if (event!=null) {
			EventQueue queue=EventQueue.getinstance();
			queue.addObject(event);
		}else {
			logger.info("json to bean failed!!");
		}
	}
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:13,代码来源:DraggedEventListener.java


示例13: onData

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
@Override
public void onData(SocketIOClient client, String serialNumber,
		AckRequest ackRequest) throws Exception {
	
	DeviceEntity deviceEntity = DeviceContainerHandler
			.getDevice(serialNumber);
	if (deviceEntity != null && deviceEntity.getMinicapEntity()!=null&&!deviceEntity.getMinicapEntity().isStoping()) {
		semaphore.acquire();
		deviceEntity.getMinicapEntity().setStoping(true);
		Minicap cap = SocketCollection.getMiniCap(serialNumber);
		if (cap != null) {
			cap.closeAll();
		}
		SocketCollection.removeMiniCap(serialNumber);

		// 从屏幕监听客户端列表中移除下线客户端

		if (ClientCollection.isContainsKey(serialNumber)) {
			List<UUID> removeList = new ArrayList<UUID>();
			Set<UUID> clients = ClientCollection.getClients(serialNumber);
			if (clients != null) {
				for (UUID client_uuid : clients) {
					if (client_uuid.equals(client.getSessionId())) {
						removeList.add(client_uuid);
					}
				}
				if (removeList != null) {
					for (UUID uuid : removeList) {
						ClientCollection.removeUUID(serialNumber, uuid);
						logger.info("stop从屏幕监听客户端列表中移除:"
								+ client.getSessionId() + " IP:"
								+ client.getRemoteAddress());
					}
				}
			}
		}
		deviceEntity.getMinicapEntity().setStoping(false);
		semaphore.release();
	}
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:41,代码来源:StopScreenMonitorListener.java


示例14: onData

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
@Override
public void onData(SocketIOClient client, String data, AckRequest ackSender)
		throws Exception {
	if (data != null) {
		CommandBean commandBean = JsonUtil.jsonTobean(data,
				CommandBean.class);
		if (commandBean != null && commandBean.getSerList() != null
				&& commandBean.getCommand() != null) {
			for (String sernum : commandBean.getSerList()) {
				executorService.execute(new Runnable() {

					@Override
					public void run() {
						DeviceEntity deviceEntity = DeviceContainerHandler
								.getDevice(sernum);
						if (deviceEntity != null) {
							IDevice idevice = deviceEntity.getIdevice();
							if (idevice.isOnline()) {
								CollectingOutputReceiver receiver = new CollectingOutputReceiver();
								try {
									idevice.executeShellCommand(
											commandBean.getCommand(),
											receiver);
								} catch (TimeoutException
										| AdbCommandRejectedException
										| ShellCommandUnresponsiveException
										| IOException e) {
									logger.error("执行命令发送异常", e);
								}
								receiver.flush();
								logger.info(receiver.getOutput());
							}
						}
					}
				});
			}
		}
	}
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:40,代码来源:CommandListener.java


示例15: onData

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
@Override
public void onData(SocketIOClient client, String str, AckRequest ackRequest)
		throws Exception {
	logger.info(str);
	OpenWebsiteBean bean = JsonUtil.jsonTobean(str, OpenWebsiteBean.class);

	// 根据设备列表统一打开网址
	if (bean != null) {
		List<String> serialNumberList = bean.getSerialNumList();
		if (serialNumberList != null && serialNumberList.size() > 0) {
			String url = bean.getUrl().trim();
			for (String serialNumber : serialNumberList) {
				DeviceEntity deviceEntity = DeviceContainerHandler
						.getDevice(serialNumber);
				if (deviceEntity != null) {
					IDevice idevice = deviceEntity.getIdevice();
					executorService.execute(new Runnable() {

						@Override
						public void run() {
							NullOutputReceiver receiver = new NullOutputReceiver();
							try {
								idevice.executeShellCommand(
										String.format(COMMAND, url),
										receiver);
							} catch (TimeoutException
									| AdbCommandRejectedException
									| ShellCommandUnresponsiveException
									| IOException e) {
								logger.error(serialNumber + ":设备打开网址:"
										+ url + "出错");
							}
						}
					});
				}
			}
		}
	}
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:40,代码来源:OpenWebsiteListener.java


示例16: onData

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
@Override
public void onData(SocketIOClient client, String serialNumber, AckRequest ackRequest) throws Exception {
	//添加客户端到屏幕中
			if (!ClientCollection.isContainsKey(serialNumber)) {
				ClientCollection.addClients(serialNumber, new TreeSet<UUID>());
			}
			if (!ClientCollection.getUUIDcontainsKey(serialNumber, client.getSessionId())) {
				ClientCollection.addUUID(serialNumber, client.getSessionId());
				logger.info("浏览器客户端加入到屏幕传输中:" + serialNumber + "," + client.getSessionId());
			}
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:12,代码来源:ClientJoinToScreen.java


示例17: onData

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
@Override
public void onData(SocketIOClient client, String data, AckRequest ackSender) throws Exception {
	data=data.trim();
	if (data!=null) {
		TouchEntityEvent event=JsonUtil.jsonTobean(data, TouchEntityEvent.class);
		if (event!=null) {
			EventQueue queue=EventQueue.getinstance();
			queue.addObject(event);
		}else {
			logger.info("json to bean failed!!");
		}
	}
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:14,代码来源:EntityEventListener.java


示例18: sendScreenImageBinary

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
/**
 * 发送图像数据到客户端
 * @param client 客户端
 * @param imageByte 图像数据
 */
public static void sendScreenImageBinary(String serialNumber,UUID uuid,byte[] imageByte){
	SocketIOClient client = server.getClient(uuid);
	if (client!=null) {
		client.sendEvent("screen.image_"+serialNumber, imageByte);
	}else {
		logger.info("找不到该客户端"+uuid.toString());
	}
	
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:15,代码来源:ScreenWSSender.java


示例19: restartMinicap

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
/**
 * 重启minicap,通过通知某一个客户端minicap下线通知。使得其重新发起屏幕启动请求
 */
public void restartMinicap() {
	// 连续收到两次的重启请求才去执行重启启动。
	if (deviceEntity.getMinicapEntity().getStatus() == Status.RUNNING
			&& restartRequestCount >= 1) {
		logger.warn("[" + deviceEntity.getSerialNumber()
				+ "]minicap退出,正在重启minicap");
		Set<UUID> uuids = ClientCollection.getClients(deviceEntity
				.getSerialNumber());
		if (uuids != null && uuids.size() > 0) {
			SocketIOServer server = WebsocketServer.getServer();
			Iterator<UUID> it = uuids.iterator();
			while (it.hasNext()) {
				SocketIOClient client = server.getClient(uuids.iterator()
						.next());
				if (client != null && client.isChannelOpen()) {
					client.sendEvent("screen.restart_screen_"
							+ deviceEntity.getSerialNumber(),
							deviceEntity.getSerialNumber());
					deviceEntity.getMinicapEntity()
							.setStatus(Status.CLOSED);
					return;
				}
			}
		}
		restartRequestCount = 0;
	}
	restartRequestCount++;
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:32,代码来源:MinicapManager.java


示例20: onData

import com.corundumstudio.socketio.SocketIOClient; //导入依赖的package包/类
@Override
public void onData(SocketIOClient client, String data, AckRequest ackSender) throws Exception {
	try {
		Integer command = Integer.valueOf(data);
		sendCommand(command);
	} catch (NumberFormatException e) {
		System.out.println("Unknown command: " + data);
	}
}
 
开发者ID:andreldm,项目名称:rcontrol,代码行数:10,代码来源:Server.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TaskHandle类代码示例发布时间:2022-05-22
下一篇:
Java UserStoreManager类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap