扫描二维码入场逻辑
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
package com.sv.service;
|
||||
|
||||
import com.sv.barcode.ClientConfig;
|
||||
import com.sv.barcode.ListenKeyFrame;
|
||||
import com.sv.netty.ClientThread;
|
||||
import com.sv.netty.config.NettyConstant;
|
||||
import com.sv.netty.utils.JsonUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 启动socker和websocket服务
|
||||
@@ -10,9 +19,41 @@ import com.sv.netty.ClientThread;
|
||||
*/
|
||||
public class ClientService {
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws IOException, InterruptedException {
|
||||
File file = new File("/home/venue/client/venue.conf");
|
||||
// File file = new File("/Users/limqhz/home/venue/client/venue.conf");
|
||||
FileReader fileReader = new FileReader(file);
|
||||
BufferedReader bufferedReader = new BufferedReader(fileReader);
|
||||
String line = bufferedReader.readLine();
|
||||
if (line != null) {
|
||||
ClientConfig decode = JsonUtils.decode(line, ClientConfig.class);
|
||||
System.setProperty(NettyConstant.VENUE_SERVER_IP,decode.getServerIp());
|
||||
System.setProperty(NettyConstant.VENUE_SERVER_PORT,decode.getServerPort());
|
||||
System.setProperty(NettyConstant.VENUE_CLIENT_SN,decode.getClientSN());
|
||||
System.setProperty(NettyConstant.VENUE_CLIENT_VID,decode.getClientVid());
|
||||
}
|
||||
bufferedReader.close();
|
||||
fileReader.close();
|
||||
|
||||
ClientThread instance = ClientThread.getInstance();
|
||||
instance.start();
|
||||
|
||||
Thread.sleep(3000);
|
||||
ListenKeyFrame listenKeyFrame = new ListenKeyFrame();
|
||||
listenKeyFrame.newFrame(1);
|
||||
Thread.sleep(3000);
|
||||
listenKeyFrame.close();
|
||||
ListenKeyFrame listenKeyFrame1 = new ListenKeyFrame();
|
||||
listenKeyFrame1.newFrame(2);
|
||||
Thread.sleep(3000);
|
||||
listenKeyFrame1.close();
|
||||
ListenKeyFrame listenKeyFrame2 = new ListenKeyFrame();
|
||||
listenKeyFrame2.newFrame(3);
|
||||
Thread.sleep(3000);
|
||||
listenKeyFrame2.close();
|
||||
ListenKeyFrame listenKeyFrame3 = new ListenKeyFrame();
|
||||
listenKeyFrame3.newFrame(4);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.sv.service;
|
||||
|
||||
import com.sv.netty.config.VenueMessage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* 消息服务
|
||||
* MessageService.java
|
||||
*
|
||||
* @author peakren
|
||||
* @date 2018/12/20 6:00 PM
|
||||
*/
|
||||
public class MessageService {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(MessageService.class);
|
||||
|
||||
static private MessageService sInstance;
|
||||
|
||||
static public MessageService getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (MessageService.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new MessageService();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
/**
|
||||
* 解析并执行接受服务器消息
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
public void execute(VenueMessage message) {
|
||||
switch (message.getMessageType()) {
|
||||
case OPEN_DOOR:
|
||||
openDoor();
|
||||
break;
|
||||
default:
|
||||
logger.info( "default");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 门禁开门
|
||||
*/
|
||||
public void openDoor() {
|
||||
// 开门
|
||||
logger.info("开门成功!!!");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user