- package com.ntlab.irisserver.models;
- import com.ntlab.irisserver.entities.Room;
- import org.springframework.stereotype.Component;
-
- import javax.ws.rs.*;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.UUID;
-
- @Component
- public class RoomManager {
- private static RoomManager theInstance = null;
- private Map<String, Room> rooms = new HashMap<String, Room>();
-
- public static RoomManager getInstance(){
- if(theInstance == null){
- theInstance = new RoomManager();
- }
- return theInstance;
- }
-
- public Room createRoom(String owner){
- UUID uuid = UUID.randomUUID();
- String rid = uuid.toString(); //uuid型からstring型に変換
- Room r = new Room(rid, owner);
- rooms.put(rid, r);
- return r;
- }
-
- public Room getRoom(String rid){
- Room r = rooms.get(rid);
- return r;
- }
-
- public void deleteRoom(String rid){
- rooms.remove(rid);
- }
-
-
- }