正在显示
3 个修改的文件
包含
61 行增加
和
1 行删除
| @@ -128,7 +128,7 @@ public class RouteController { | @@ -128,7 +128,7 @@ public class RouteController { | ||
| 128 | 128 | ||
| 129 | CIMUserInfo cimUserInfo = userInfoCacheService.loadUserInfoByUserId(groupReqVO.getUserId()); | 129 | CIMUserInfo cimUserInfo = userInfoCacheService.loadUserInfoByUserId(groupReqVO.getUserId()); |
| 130 | 130 | ||
| 131 | - LOGGER.info("下线用户[{}]", cimUserInfo.toString()); | 131 | + LOGGER.info("user [{}] offline!", cimUserInfo.toString()); |
| 132 | accountService.offLine(groupReqVO.getUserId()); | 132 | accountService.offLine(groupReqVO.getUserId()); |
| 133 | 133 | ||
| 134 | res.setCode(StatusEnum.SUCCESS.getCode()); | 134 | res.setCode(StatusEnum.SUCCESS.getCode()); |
cim-forward-route/src/main/java/com/crossoverjie/cim/route/kit/NetAddressIsReachable.java
0 → 100644
| 1 | +package com.crossoverjie.cim.route.kit; | ||
| 2 | + | ||
| 3 | +import java.io.IOException; | ||
| 4 | +import java.net.InetSocketAddress; | ||
| 5 | +import java.net.Socket; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * Function: | ||
| 9 | + * | ||
| 10 | + * @author crossoverJie | ||
| 11 | + * Date: 2020-04-12 20:32 | ||
| 12 | + * @since JDK 1.8 | ||
| 13 | + */ | ||
| 14 | +public class NetAddressIsReachable { | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * check ip and port | ||
| 18 | + * | ||
| 19 | + * @param address | ||
| 20 | + * @param port | ||
| 21 | + * @param timeout | ||
| 22 | + * @return True if connection successful | ||
| 23 | + */ | ||
| 24 | + public static boolean checkAddressReachable(String address, int port, int timeout) { | ||
| 25 | + Socket socket = new Socket() ; | ||
| 26 | + try { | ||
| 27 | + socket.connect(new InetSocketAddress(address, port), timeout); | ||
| 28 | + return true; | ||
| 29 | + } catch (IOException exception) { | ||
| 30 | + return false; | ||
| 31 | + } finally { | ||
| 32 | + try { | ||
| 33 | + socket.close(); | ||
| 34 | + } catch (IOException e) { | ||
| 35 | + return false ; | ||
| 36 | + } | ||
| 37 | + } | ||
| 38 | + } | ||
| 39 | +} |
| 1 | +import com.crossoverjie.cim.route.kit.NetAddressIsReachable; | ||
| 2 | +import org.junit.Test; | ||
| 3 | + | ||
| 4 | +/** | ||
| 5 | + * Function: | ||
| 6 | + * | ||
| 7 | + * @author crossoverJie | ||
| 8 | + * Date: 2020-04-12 18:38 | ||
| 9 | + * @since JDK 1.8 | ||
| 10 | + */ | ||
| 11 | +public class CommonTest { | ||
| 12 | + | ||
| 13 | + @Test | ||
| 14 | + public void test() { | ||
| 15 | + boolean reachable = NetAddressIsReachable.checkAddressReachable("127.0.0.1", 11211, 1000); | ||
| 16 | + System.out.println(reachable); | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | +} |
-
请 注册 或 登录 后发表评论