zhoufan преди 1 година
родител
ревизия
cb17f9603e

+ 24 - 8
midware-service/src/main/java/midware/service/init/EslClientService.java

@@ -48,6 +48,14 @@ public class EslClientService {
48 48
         new ScheduledThreadPoolExecutor(1).scheduleAtFixedRate(() -> {
49 49
             if (!client.canSend()) {
50 50
                 try {
51
+                    if (EslCommon.agents.size() > 0) {
52
+                        for (Agent a : EslCommon.agents) {
53
+                            logout(a.getAgent(), a.getGroup());
54
+                            a.setAgentState(EslAgentEnum.logout.ordinal());
55
+                        }
56
+                        EslCommon.agents=new ArrayList<>();
57
+                    }
58
+
51 59
                     client.connect(config.getHost(), config.getPort(), config.getPassword(), config.getTimeout());
52 60
                     //移除事件
53 61
                     client.cancelEventSubscriptions();
@@ -70,14 +78,6 @@ public class EslClientService {
70 78
                     } catch (Exception e1) {
71 79
                     }
72 80
                 }
73
-            }else {
74
-                if (EslCommon.agents.size() > 0) {
75
-                    for (Agent a : EslCommon.agents) {
76
-                        logout(a.getAgent(), a.getGroup());
77
-                        a.setAgentState(EslAgentEnum.logout.ordinal());
78
-                    }
79
-                    EslCommon.agents=new ArrayList<>();
80
-                }
81 81
             }
82 82
         }, 1, 5000, TimeUnit.MILLISECONDS);
83 83
 
@@ -379,6 +379,22 @@ public class EslClientService {
379 379
         return result;
380 380
     }
381 381
 
382
+    //放音收号
383
+    public String playAndGetDigits(String path, String chanId) {
384
+        String result = "";
385
+        try {
386
+            String command = EslCommandEnum.uuid_broadcast.name();
387
+            path = "/home/wav/8001.wav";
388
+
389
+            String arg = chanId + " 'play_and_get_digits::1 1 2 2000 # " + path + " silence_stream://250 res \\d+'";
390
+            result = client.sendAsyncApiCommand(command, arg);
391
+
392
+        } catch (Exception e) {
393
+            log.error(chanId + " 放音收号失败", e);
394
+        }
395
+        return result;
396
+    }
397
+
382 398
     //会话加入会议
383 399
     public String talkJoinMeeting(String sessionId) {
384 400
         String result = "";

+ 13 - 8
midware-util/src/main/java/midware/util/helper/IpHelper.java

@@ -27,26 +27,31 @@ public class IpHelper {
27 27
         return hostIP;
28 28
     }
29 29
 
30
-    public static String getMac(){
31
-        String mac="";
30
+    public static String getMac() {
31
+        String mac = "";
32 32
         try {
33 33
             Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
34 34
             while (networkInterfaces.hasMoreElements()) {
35 35
                 NetworkInterface ni = networkInterfaces.nextElement();
36
-                if (ni.isLoopback() || ni.isVirtual() || !ni.isUp()) {
37
-                    continue;
36
+                if (ni.isLoopback() || ni.isVirtual() || !ni.isUp()) continue;
37
+                boolean ip4 = false;
38
+                Enumeration<InetAddress> nias = ni.getInetAddresses();
39
+                while (nias.hasMoreElements()) {
40
+                    InetAddress ia = nias.nextElement();
41
+                    if (!ia.isLinkLocalAddress() && !ia.isLoopbackAddress() && ia instanceof Inet4Address) {
42
+                        ip4 = true;
43
+                    }
38 44
                 }
45
+                if (!ip4) continue;
39 46
                 byte[] macByte = ni.getHardwareAddress();
40
-                if (macByte == null) {
41
-                    continue;
42
-                }
47
+                if (macByte == null) continue;
43 48
                 StringBuilder buf = new StringBuilder();
44 49
                 for (byte aMac : macByte) {
45 50
                     buf.append(String.format("%02X-", aMac));
46 51
                 }
47 52
                 if (buf.length() > 0) {
48 53
                     buf.deleteCharAt(buf.length() - 1);
49
-                    mac=buf.toString();
54
+                    mac = buf.toString();
50 55
                     break;
51 56
                 }
52 57
             }