| | |
| | | package com.whyc.webSocket; |
| | | |
| | | import com.whyc.config.WebSocketConfig; |
| | | import com.whyc.dto.LockRDto; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.service.LockInfService; |
| | | import com.whyc.util.JsonUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | } |
| | | @OnMessage |
| | | public void onMessage(Session session, String message) { |
| | | Integer areaId=Integer.valueOf(message); |
| | | LockRDto dto= JsonUtil.getGson().fromJson(message,LockRDto.class); |
| | | thread = new Thread("Thread_lockRtSocket") { |
| | | @Override |
| | | public void run() { |
| | |
| | | Thread thread = currentThread(); |
| | | threadFlagMap.put(thread.getId(), true); |
| | | try { |
| | | Response res=getLockRt(areaId); |
| | | Response res=getLockRt(dto); |
| | | if (session.isOpen()) { |
| | | //推送信息 |
| | | synchronized (session) { |
| | |
| | | threadMap.put(session.getId(), this.thread); |
| | | } |
| | | //获取区域下所有锁的状态 |
| | | private Response getLockRt(int areaId) { |
| | | Response res=lockInfService.getLockRt(areaId); |
| | | private Response getLockRt(LockRDto dto) { |
| | | Response res=lockInfService.getAllLockInf(dto.getLockName(),dto.getLockType(),dto.getLockState(),dto.getAreaId(),dto.getPageNum(),dto.getPageSize()); |
| | | return new Response().setII(1,true,res,"获取区域下所有锁的状态"); |
| | | } |
| | | |