2016-08-30 54 views
0

我想與刪除活躍熱點用戶下面的代碼,但是他說:刪除熱點的活躍用戶

沒有這樣的項目

mikrotik.Send("/ip/hotspot/active/remove"); 
mikrotik.Send("=.id=" + username,true); 
下面

是的MikroTik熱點的截圖 enter image description here

回答

1

執行此操作的最佳方法是找到正確的通過執行活動熱用戶的.ID ...

/ip/hotspot/active/print 

您將收到的活躍用戶像這樣的列表:

[tag=3, data={idle-time=6s, uptime=47s, bytes-out=121490,.id=*AC100016, mac-address=2C:AE:2B:9A:22:37, packets-out=314, session-time-left=59m13s, login-by=http-chap, bytes-in=47381, address=172.16.0.22, radius=false, server=SERVER_TEST, user=0872test, packets-in=330}] 

在這種情況下,你需要的是.ID .id = * AC100016

現在,我給你和我​​的方法的例子deleteActiveUser()。它已經完成Java,但在我看來很明顯:

public boolean deleteActiveUser(String id_param){ 
     boolean ret = true; 
     try { 
      StringBuilder sb = new StringBuilder(); 
      sb.append("/ip/hotspot/active/remove .id="); 
      sb.append(id_param); 

      this.getConnection(this.mikrotik).execute(sb.toString()); 

      } catch (MikrotikApiException e) { 
       ret = false; 
      e.printStackTrace(); 

     } catch (NullPointerException ex) { 
      ex.printStackTrace(); 
      ret = false; 

     } finally { 

      closeConnection(); 
     } 

     return ret; 

    }