[+] 创建会议
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.acgist.taoyao.meeting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -13,5 +15,16 @@ import lombok.Setter;
|
||||
@Setter
|
||||
@Schema(title = "会议", description = "会议")
|
||||
public class Meeting {
|
||||
|
||||
/**
|
||||
* 会议标识
|
||||
*/
|
||||
@Schema(title = "会议标识", description = "会议标识")
|
||||
private String id;
|
||||
/**
|
||||
* 终端会话标识列表
|
||||
*/
|
||||
@Schema(title = "终端会话标识列表", description = "终端会话标识列表")
|
||||
private List<String> sns;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,53 @@
|
||||
package com.acgist.taoyao.meeting;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 房间
|
||||
* 会议管理
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MeetingManager {
|
||||
|
||||
/**
|
||||
* 会议列表
|
||||
*/
|
||||
private List<Meeting> meetings = new CopyOnWriteArrayList<>();
|
||||
|
||||
/**
|
||||
* @return 所有会议列表
|
||||
*/
|
||||
public List<Meeting> meetings() {
|
||||
return this.meetings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id 会议标识
|
||||
*
|
||||
* @return 会议信息
|
||||
*/
|
||||
public Meeting meeting(String id) {
|
||||
return this.meetings.stream()
|
||||
.filter(v -> v.getId().equals(id))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id 会议标识
|
||||
*
|
||||
* @return 会议所有终端标识
|
||||
*/
|
||||
public List<String> sns(String id) {
|
||||
final Meeting meeting = this.meeting(id);
|
||||
return meeting == null ? List.of() : meeting.getSns();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.acgist.taoyao.meeting.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -7,6 +8,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.acgist.taoyao.boot.model.Message;
|
||||
import com.acgist.taoyao.meeting.Meeting;
|
||||
import com.acgist.taoyao.meeting.MeetingManager;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
@@ -24,23 +26,26 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@RequestMapping("/meeting")
|
||||
public class MeetingController {
|
||||
|
||||
@Autowired
|
||||
private MeetingManager meetingManager;
|
||||
|
||||
@Operation(summary = "会议列表", description = "会议列表")
|
||||
@GetMapping("/list")
|
||||
@ApiResponse(content = @Content(schema = @Schema(implementation = Meeting.class)))
|
||||
public Message list() {
|
||||
return Message.success();
|
||||
return Message.success(this.meetingManager.meetings());
|
||||
}
|
||||
|
||||
@Operation(summary = "会议状态", description = "会议状态")
|
||||
@GetMapping("/status/{id}")
|
||||
public Message status(@PathVariable String id) {
|
||||
return Message.success();
|
||||
return Message.success(this.meetingManager.meeting(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "会议终端列表", description = "会议终端列表")
|
||||
@GetMapping("/list/client")
|
||||
public Message listClient() {
|
||||
return Message.success();
|
||||
@GetMapping("/list/client/{id}")
|
||||
public Message listClient(@PathVariable String id) {
|
||||
return Message.success(this.meetingManager.sns(id));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.acgist.taoyao.meeting.listener;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.acgist.taoyao.boot.model.Message;
|
||||
import com.acgist.taoyao.meeting.MeetingManager;
|
||||
import com.acgist.taoyao.signal.client.ClientSession;
|
||||
import com.acgist.taoyao.signal.event.meeting.MeetingCreateEvent;
|
||||
import com.acgist.taoyao.signal.listener.ApplicationListenerAdapter;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 创建会议监听
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MeetingCreateListener extends ApplicationListenerAdapter<MeetingCreateEvent> {
|
||||
|
||||
@Autowired
|
||||
private MeetingManager meetingManager;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(MeetingCreateEvent event) {
|
||||
// this.meetingManager.create();
|
||||
final ClientSession session = event.getSession();
|
||||
final Message message = event.getMessage();
|
||||
message.setBody(Map.of("id", "1234"));
|
||||
session.push(message);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user