Skip to content

Commit

Permalink
Merge pull request #8 from depth-rolling-paper/develop
Browse files Browse the repository at this point in the history
feat: 방 생성 소켓 추가
  • Loading branch information
phonil authored Dec 18, 2023
2 parents 6f36e82 + 74fdbcd commit f2f4abd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.rollingpaperserver.domain.waitingRoom.domain.WaitingRoom;
import com.rollingpaperserver.domain.waitingRoom.domain.repository.WaitingRoomRepository;
import com.rollingpaperserver.domain.waitingRoom.dto.response.FindWaitingRoomRes;
import com.rollingpaperserver.global.config.WebSocketEventListener;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
Expand All @@ -32,6 +33,8 @@ public class RoomService {
private final UserRepository userRepository;
private final RollingPaperRepository rollingPaperRepository;

private final WebSocketEventListener webSocketEventListener;

// Description : 방 생성 + 유저 이동 포함
@Transactional
public ResponseEntity<?> createRoom(String url) {
Expand Down Expand Up @@ -70,6 +73,8 @@ public ResponseEntity<?> createRoom(String url) {
// Description : 대기 방 삭제
waitingRoomRepository.delete(waitingRoom);

webSocketEventListener.sendUrl(url);

CreateRoomRes createRoomRes = CreateRoomRes.builder()
.id(room.getId())
.roomName(room.getRoomName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ public void sendUserCountUpdate(String waitingRoomUrl, int userCount) {
// Description : 유저 수 업데이트, 업데이트 된 유저 수 보내기
messagingTemplate.convertAndSend("/topic/" + waitingRoomUrl, userCount);
}

public void sendUrl(String roomUrl) {
messagingTemplate.convertAndSend("/topic/" + roomUrl, roomUrl);
}
}

0 comments on commit f2f4abd

Please sign in to comment.