xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 6.37MB
    文件類型: .7z
    金幣: 1
    下載: 0 次
    發布日期: 2023-11-14
  • 語言: 其他
  • 標簽: Servlet??jsp??java??web??

資源簡介

1. Websocket 編程,包括基于Tomcat8的文本和二進制讀寫,和瀏覽器端的編程 2. 提供貪吃蛇案例,包括服務端程序和網頁端,服務端是控制蛇運動方向的 3. 提供嵌入式端能過Websocket控制燈亮度,嵌入式代碼另外上傳

資源截圖

代碼片段和文件信息

package?com.iweb.socket;

import?java.util.HashMap;
import?java.util.Map;

import?javax.websocket.OnClose;
import?javax.websocket.OnMessage;
import?javax.websocket.OnOpen;
import?javax.websocket.Session;
import?javax.websocket.server.ServerEndpoint;

@ServerEndpoint(“/websocket/light“)
public?class?LightServer?{

private?static?Map?sessionMap?=?new?HashMap();

private?static?int?preDi;

@OnOpen
public?void?onOpen(){
//System.out.println(“WEBopen“);
}

@OnClose
public?void?onClose(){
//System.out.println(“WEBCLOSE“);
}

@OnMessage
public?void?onMessage(Session?session?String?msg){
//System.out.println(“received?message:?“?+?msg?+?“?session?id:?“?+?session.getId()?+?“?this:?“?+?this);
System.out.println(“received?message?on?light:?“?+?msg);
int?di?=?Integer.parseInt(msg); //0~255:亮度調節?-1:嵌入式端發來請求
if(di?==?preDi){
return;
}
if(session.isOpen()){
Session?waitCommandSession?=?sessionMap.get(“waitCommand“);
try?{
if(di?>=?0){//控制頁面發來的
try{
if(waitCommandSession?==?null){
session.getBasicRemote().sendText(“目的地找不到!“);
}else{
if(waitCommandSession.isOpen()){
waitCommandSession.getBasicRemote().sendText(di+““);
preDi?=?di;
}
}
}catch(Exception?e){
e.printStackTrace();
}
}else{//-1
if(waitCommandSession?!=?null?&&?waitCommandSession.isOpen()){
waitCommandSession.close();
}
sessionMap.put(“waitCommand“?session);
}
}?catch?(Exception?e)?{
e.printStackTrace();
}
}
}


}

評論

共有 條評論