| | package com.ntlab.irisserver.resources; |
---|
| | |
---|
| | import com.ntlab.irisserver.entities.Game; |
---|
| | import com.ntlab.irisserver.models.KeywordManager; |
---|
| | import org.springframework.beans.BeansException; |
---|
| | import org.springframework.context.ApplicationContext; |
---|
| | import org.springframework.context.ApplicationContextAware; |
---|
| | import org.springframework.stereotype.Component; |
---|
| | import com.ntlab.irisserver.entities.Room; |
---|
| | import com.ntlab.irisserver.models.RoomManager; |
---|
| | |
---|
| | import javax.ws.rs.*; |
---|
| | import javax.ws.rs.core.MediaType; |
---|
| | import javax.ws.rs.core.Response; |
---|
| | import java.io.IOException; |
---|
| | |
---|
| | |
---|
| | @Component |
---|
| | @Path("/rooms") |
---|
| | |
---|
| | public class StateRest { |
---|
| | public class StateRest implements ApplicationContextAware { |
---|
| | private ApplicationContext applicationContext; |
---|
| | |
---|
| | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { |
---|
| | this.applicationContext = applicationContext; |
---|
| | } |
---|
| | @GET//部屋の情報を入手 |
---|
| | |
---|
| | @Path("/{rid}/state") |
---|
| | |
---|
| |
---|
| | |
---|
| | @Path("/{rid}/state") |
---|
| | |
---|
| | //rid,nickname,stateを引数として持ってくる |
---|
| | public void putState(@PathParam("rid") String rid,@FormParam("nickname") String nickname,@FormParam("state") Integer state) { |
---|
| | public void putState(@PathParam("rid") String rid,@FormParam("nickname") String nickname,@FormParam("state") Integer state) throws IOException { |
---|
| | |
---|
| | RoomManager rm = RoomManager.getInstance(); |
---|
| | Room room = rm.getRoom(rid); |
---|
| | |
---|
| | |
---|
| | if(nickname.equals(room.ownerName)){ //nicknameがownerだった場合 |
---|
| | room.setState(state); //部屋の情報を変更 |
---|
| | if (state == 2) { |
---|
| | String path; |
---|
| | path = applicationContext.getResource("file:").getFile().getAbsolutePath()+"/apache-tomcat-9.0.10/webapps/irisdata/keywords.txt"; |
---|
| | //path = "C:\\Users\\student\\IdeaProjects\\IrisServer\\src\\main\\java\\com\\ntlab\\irisserver\\tmp\\keywords.txt"; |
---|
| | KeywordManager km = KeywordManager.getInstance(); |
---|
| | String[] keywords = km.getKeywords(path); |
---|
| | Game game = new Game(room, keywords); |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | |
---|
| | |
No description provided.
gameをStateRestで作成するように変更
4a978d9
intomaster
fromGame
on 1 Jul 2022