-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from snuhcs-course/new-feat/multiroom-clean
Feat: multiroom & history UI (commit cleaned version)
- Loading branch information
Showing
62 changed files
with
2,772 additions
and
55 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
153 changes: 153 additions & 0 deletions
153
android/RunUsAndroid/app/src/main/java/MultiMode/MultiModeRoom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
package MultiMode; | ||
|
||
import java.io.Serializable; | ||
import java.time.LocalDateTime; | ||
import java.time.LocalTime; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class MultiModeRoom implements Serializable { | ||
|
||
|
||
private static final long serialVersionUID = 1L; | ||
private int id; // 룸 ID | ||
private List<MultiModeUser> userList; //유저 정보 | ||
private MultiModeUser roomOwner; // 방장 | ||
|
||
private RoomCreateInfo roomCreateInfo; //방 정보 | ||
|
||
private String title; //방 제목 | ||
private double distance; //목표 거리 | ||
private int numRunners; //제한 인원 | ||
|
||
private LocalDateTime startTime; //시작 시각 | ||
|
||
private LocalTime duration; //목표 시간(달리는 시간) | ||
|
||
public MultiModeRoom(int roomId, RoomCreateInfo roomCreateInfo) { // 유저가 방을 만들때 | ||
userList = new ArrayList(); | ||
this.id = roomId; | ||
this.roomCreateInfo = roomCreateInfo; | ||
this.title = roomCreateInfo.getTitle(); | ||
this.distance = roomCreateInfo.getDistance(); | ||
this.startTime = roomCreateInfo.getStartTime(); | ||
this.duration = roomCreateInfo.getDuration(); | ||
this.numRunners = roomCreateInfo.getNumRunners(); | ||
} | ||
public MultiModeRoom(MultiModeUser user ) { // 유저가 방을 만들때 | ||
userList = new ArrayList(); | ||
user.enterRoom(this); | ||
userList.add(user); // 유저를 추가시킨 후 | ||
this.roomOwner = user; // 방장을 유저로 만든다. | ||
|
||
} | ||
|
||
public MultiModeRoom() { | ||
|
||
} | ||
|
||
public void enterUser(MultiModeUser user){ | ||
user.enterRoom(this); | ||
userList.add(user); | ||
} | ||
|
||
public void exitUser(MultiModeUser user){ | ||
user.exitRoom(this); | ||
userList.remove(user); | ||
|
||
if(userList.size() < 1){ | ||
RoomManager.removeRoom(this); | ||
return; | ||
} | ||
|
||
if(this.roomOwner.equals(user)){ | ||
this.roomOwner = userList.get(0); | ||
return; | ||
} | ||
} | ||
|
||
public void close(){ | ||
for(MultiModeUser user : userList){ | ||
user.exitRoom(this); | ||
this.userList.clear(); | ||
this.userList = null; | ||
} | ||
} | ||
|
||
public void broadcast(byte[] data){ | ||
|
||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
MultiModeRoom multiModeRoom = (MultiModeRoom) o; | ||
|
||
return id == multiModeRoom.id; | ||
} | ||
|
||
|
||
public String getTitle() { // 방 이름을 가져옴 | ||
return title; | ||
} | ||
|
||
public double getDistance() { return distance;} | ||
|
||
public LocalDateTime getStartTime() {return startTime;} | ||
|
||
public int getNumRunners() {return numRunners;} | ||
|
||
public int getUserSize() { // 유저의 수를 리턴 | ||
return userList.size(); | ||
} | ||
|
||
public MultiModeUser getOwner() { // 방장을 리턴 | ||
return roomOwner; | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
public List getUserList() { | ||
return userList; | ||
} | ||
|
||
public void setUserList(List userList) { | ||
this.userList = userList; | ||
} | ||
|
||
public MultiModeUser getRoomOwner() { | ||
return roomOwner; | ||
} | ||
|
||
public void setRoomOwner(MultiModeUser roomOwner) { | ||
this.roomOwner = roomOwner; | ||
} | ||
|
||
public LocalTime getDuration(){ | ||
return duration; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "MultiModeRoom{" + | ||
"id=" + id + | ||
", userList=" + userList + | ||
", roomOwner=" + roomOwner + | ||
", roomCreateInfo=" + roomCreateInfo + | ||
'}'; | ||
} | ||
|
||
} |
78 changes: 78 additions & 0 deletions
78
android/RunUsAndroid/app/src/main/java/MultiMode/MultiModeUser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package MultiMode; | ||
|
||
import java.io.Serializable; | ||
import java.net.Socket; | ||
|
||
public class MultiModeUser implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
|
||
private int id; | ||
private MultiModeRoom room; | ||
private Socket socket; | ||
private String nickname; | ||
|
||
public MultiModeUser(String nickName){ | ||
this.nickname = nickname; | ||
} | ||
|
||
public MultiModeUser(int id, String nickname){ | ||
this.id = id; | ||
this.nickname = nickname; | ||
} | ||
|
||
public void enterRoom(MultiModeRoom room){ | ||
this.room = room; | ||
} | ||
|
||
public void exitRoom(MultiModeRoom room){ | ||
this.room = null; | ||
} | ||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
public String getNickname() {return this.nickname; } | ||
|
||
public void setnickname(String nickname){ | ||
this.nickname = nickname; | ||
} | ||
|
||
public MultiModeRoom getRoom() { | ||
return room; | ||
} | ||
|
||
public void setRoom(MultiModeRoom room) { | ||
this.room = room; | ||
} | ||
|
||
public Socket getSock() { | ||
return socket; | ||
} | ||
|
||
public void setSock(Socket socket) { | ||
this.socket = socket; | ||
} | ||
|
||
public String getNickName() { | ||
return nickname; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
MultiModeUser gameUser = (MultiModeUser) o; | ||
|
||
return id == gameUser.id; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return id; | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
android/RunUsAndroid/app/src/main/java/MultiMode/Packet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package MultiMode; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
public class Packet implements Serializable { //서버와 통신하기 위해 사용하는 클래스. Protocol + 필요한 정보 넣어서 전송 및 수신 | ||
private static final long serialVersionUID = 1L; | ||
|
||
// 데이터 유형을 나타내는 필드 | ||
private int protocol; | ||
|
||
private RoomCreateInfo roomCreateInfo = null; | ||
|
||
// 실제 데이터 | ||
private MultiModeUser user; | ||
|
||
private MultiModeRoom selectedRoom = null; | ||
|
||
private List<MultiModeRoom> roomList = null; | ||
|
||
public Packet(int protocol, MultiModeUser user) { | ||
this.protocol = protocol; | ||
this.user = user; | ||
} | ||
|
||
public Packet(int protocol, MultiModeRoom selectedRoom) { | ||
this.protocol = protocol; | ||
this.selectedRoom = selectedRoom; | ||
} | ||
|
||
public Packet(int protocol, MultiModeUser user, RoomCreateInfo roomCreateInfo ){ | ||
this.protocol = protocol; | ||
this.user = user; | ||
this.roomCreateInfo = roomCreateInfo; | ||
} | ||
|
||
public Packet(int protocol, MultiModeUser user, MultiModeRoom selectedRoom ){ | ||
this.protocol = protocol; | ||
this.user = user; | ||
this.selectedRoom = selectedRoom; | ||
} | ||
|
||
public Packet(int protocol, List<MultiModeRoom> roomList ){ | ||
this.protocol = protocol; | ||
this.roomList = roomList; | ||
} | ||
|
||
public Packet(int protocol, List<MultiModeRoom> roomList, MultiModeRoom selectedRoom ){ | ||
this.protocol = protocol; | ||
this.roomList = roomList; | ||
this.selectedRoom = selectedRoom; | ||
} | ||
|
||
|
||
|
||
public int getProtocol() { | ||
return protocol; | ||
} | ||
|
||
public MultiModeUser getUser() { | ||
return user; | ||
} | ||
|
||
public RoomCreateInfo getRoomCreateInfo() {return roomCreateInfo; } | ||
|
||
public MultiModeRoom getSelectedRoom() {return selectedRoom;} | ||
|
||
public List<MultiModeRoom> getRoomList() {return roomList;} | ||
} |
12 changes: 12 additions & 0 deletions
12
android/RunUsAndroid/app/src/main/java/MultiMode/Protocol.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package MultiMode; | ||
|
||
public class Protocol { | ||
public static final int ROOM_LIST = 1; | ||
public static final int CREATE_ROOM = 2; | ||
public static final int ENTER_ROOM = 3; | ||
public static final int EXIT_ROOM = 4; | ||
// 다른 프로토콜 상수 추가 | ||
public static final int UPDATE_ROOM = 5; | ||
public static final int UPDATE_EVERY_ROOM = 6; | ||
} | ||
|
Oops, something went wrong.