|
@@ -0,0 +1,42 @@
|
|
|
+package cn.com.ty.lift.ud.neety.process;
|
|
|
+
|
|
|
+import cn.com.ty.lift.ud.neety.protocol.IMMessage;
|
|
|
+import cn.com.ty.lift.ud.neety.protocol.IMP;
|
|
|
+import cn.com.ty.lift.ud.neety.support.WebSoketSupport;
|
|
|
+import cn.com.ty.lift.ud.neety.task.RoomInfo;
|
|
|
+import cn.com.ty.lift.ud.neety.task.UserInfo;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import io.netty.channel.Channel;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+public class LoadUsersProcessor extends WebSoketSupport implements ProcessorInterface {
|
|
|
+ @Override
|
|
|
+ public void process(Channel client, IMMessage request) {
|
|
|
+ String currentUserId = client.attr(USERID).get();
|
|
|
+ String currentUserHead = client.attr(HEAD_PIC).get();
|
|
|
+ String currentUserName = client.attr(USERNAME).get();
|
|
|
+
|
|
|
+ Optional.ofNullable(redis.get("ROOM:" + request.getSessionid())).ifPresent(s -> {
|
|
|
+ RoomInfo roomInfo = JSONObject.parseObject(s, RoomInfo.class);
|
|
|
+ IMMessage msg = new IMMessage();
|
|
|
+ msg.setCmd(IMP.LOADUSERS.getName());
|
|
|
+ List<UserInfo> userList = roomInfo.getUserList();
|
|
|
+ Iterator<UserInfo> iterator = userList.iterator();
|
|
|
+ while (iterator.hasNext()){
|
|
|
+ UserInfo userInfo = iterator.next();
|
|
|
+ if (currentUserId.equals(userInfo.getUserId())){
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ msg.setMsg(JSONObject.toJSONString(userList));
|
|
|
+
|
|
|
+ sendMessage(client, msg);
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+}
|