在线状态问题。两端在线的时候,一端断网,退出应用或者杀死应用,另一端始终会显示退出的用户为在线状态

BiDoctor 2023-7-12 750

// 手机在线、web在线、pc在线 public @NonNull String desc() { if (this.customState > 0) { //0,未设置,1 忙碌,2 离开(主动设置),3 离开(长时间不操作),4 隐身,其它可以自主扩展。 String[] cs = new String[]{"未设置", "忙碌", "离开(主动离开)", "离开(长时间未操作)", "隐身"}; //return this.customText + cs[this.customState]; return "离线"; }

  • String onlineClientDesc = "";
  • String lastSeenDesc = "";
  • for (ClientState s : clientStates) {
  • //
  • // /**
  • // Platform_UNSET = 0;
  • // Platform_iOS = 1;
  • // Platform_Android = 2;
  • // Platform_Windows = 3;
  • // Platform_OSX = 4;
  • // Platform_WEB = 5;
  • // Platform_WX = 6;
  • // Platform_LINUX = 7;
  • // Platform_iPad = 8;
  • // Platform_APad = 9;
  • // */
  • // platform;
  • //
  • // //设备的在线状态,0是在线,1是有session但不在线,其它不在线。
  • // state;
  • //
  • // //最后可见
  • // lastSeen;
  • String[] ps = new String[]{"", "iOS", "Android", "Windows", "mac", "Web", "小程序", "Linux", "iPad", "Android-Pad"};
  • if (s.getState() == 0) {
  • //if (System.currentTimeMillis() - s.getLastSeen() < 10 * 1000) {
  • onlineClientDesc += ps[s.getPlatform()] + " ";
  • //}
  • } else {
  • // TODO
  • lastSeenDesc += ps[s.getPlatform()] + " ";
  • }
  • }
  • if (!TextUtils.isEmpty(onlineClientDesc.trim())) {
  • //return onlineClientDesc + "在线";
  • return "在线";
  • } else if (!TextUtils.isEmpty(lastSeenDesc.trim())) {
  • //return lastSeenDesc + "不久前在线";
  • return "离线";
  • }
  • //return "不在线";
  • //return "";
  • return "离线";
  • }
最新回复 (1)
  • x86 2023-7-12
    引用 2
    用 demo 能否复现,怎么复现?
返回