zouxuan 4 years ago
parent
commit
64d12cfb3c

+ 22 - 1
edu-im/edu-im-server/src/main/java/com/keao/edu/im/controller/RoomController.java

@@ -12,6 +12,7 @@ import com.keao.edu.im.service.MessageService;
 import com.keao.edu.im.service.RoomService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -29,6 +30,8 @@ public class RoomController{
     MessageService messageService;
     @Autowired
     SysUserFeignService sysUserFeignService;
+    @Autowired
+    private RedisTemplate<String,String> redisTemplate;
 
     @RequestMapping(value = "/join", method = RequestMethod.POST)
     public BaseResponse joinRoom(@RequestBody ReqUserData data)
@@ -65,7 +68,25 @@ public class RoomController{
     public Object statusSync(@RequestBody String body) throws Exception {
         ChannelStateNotify notify = JSONObject.parseObject(body, ChannelStateNotify.class);
         log.info("statusSyncParam: {}",JSONObject.toJSON(notify));
-        roomService.statusSync(notify);
+        String roomId = notify.getRoomId();
+        String userId = notify.getUserId();
+        switch (notify.getEvent()){
+            case 3:
+                log.info("房间销毁 roomId: {}, userId: {}",roomId, userId);
+                redisTemplate.delete("sessionId:" + roomId);
+                break;
+            case 11:
+                //成员加入
+                roomService.joinRoomSuccess(roomId, userId);
+                break;
+            case 12:
+                //成员退出
+                roomService.leaveRoomSuccess(roomId, userId);
+                break;
+            case 20:
+                roomService.resourceChange(roomId, userId,notify.getMembers());
+                break;
+        }
         return new BaseResponse<>();
     }