Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multimode/play 멀티모드 화면 일부 변경 및 소켓 통신 오류 해결 #42

Merged
merged 12 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.Queue;

public class MultiModeRoom implements Serializable {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1344949L;
private final int GAME_STARTED = 1;
private final int GAME_NOT_STARTED = 0;
private final transient List<ObjectOutputStream> clientOutputStreams = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.net.Socket;

public class MultiModeUser implements Serializable {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 2194848L;

private long id;
private MultiModeRoom room;
Expand Down
11 changes: 10 additions & 1 deletion android/RunUsAndroid/app/src/main/java/MultiMode/Packet.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

public class Packet implements Serializable { //서버와 통신하기 위해 사용하는 클래스. Protocol + 필요한 정보 넣어서 전송 및 수신
private static final long serialVersionUID = 1L;
UserDistance[] top3UserDistance = null;
List<UserDistance> listTop3UserDistance = null;
// 데이터 유형을 나타내는 필드
private final int protocol;
UserDistance[] top3UserDistance = null;
private RoomCreateInfo roomCreateInfo = null;
// 실제 데이터
private MultiModeUser user;
Expand Down Expand Up @@ -74,6 +75,11 @@ public Packet(int protocol, UserDistance[] top3UserDistance, long groupHistoryId
this.groupHistoryId = groupHistoryId;
}

public Packet(int protocol, List<UserDistance> lTop3UserDistances, int temp) {
this.protocol = protocol;
this.listTop3UserDistance = lTop3UserDistances;
}

public Packet(int protocol, MultiModeUser user, float distance) {
this.protocol = protocol;
this.user = user;
Expand All @@ -83,6 +89,9 @@ public Packet(int protocol, MultiModeUser user, float distance) {
public long getGroupHistoryId() {
return groupHistoryId;
}
public List<UserDistance> getListTop3UserDistance() {
return listTop3UserDistance;
}

public void setGroupHistoryId(long groupHistoryId) {
this.groupHistoryId = groupHistoryId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.io.Serializable;

public class UserDistance implements Serializable {

private static final long serialVersionUID = 1931380L;

MultiModeUser user;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public ViewHolder(@NonNull View itemView) {
private class EnterRoomTask extends AsyncTask<Void, Void, Boolean> {
private final Context mContext;
private final NavController navcon;
private boolean isRoomFull;
Packet packet;

public EnterRoomTask(Context context, NavController navcon) {
Expand All @@ -140,6 +141,7 @@ public EnterRoomTask(Context context, NavController navcon) {
protected Boolean doInBackground(Void... voids) {
Socket socket = null;
boolean success = true;
isRoomFull = false;
try {
socketManager.openSocket(); // 소켓 연결

Expand All @@ -161,6 +163,10 @@ protected Boolean doInBackground(Void... voids) {
printRoomInfo(packet.getSelectedRoom());
}
}
else{
success = false;
isRoomFull = true;
}
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
success = false;
Expand All @@ -171,8 +177,6 @@ protected Boolean doInBackground(Void... voids) {
@Override
protected void onPostExecute(Boolean success) { //doInBackground()의 return값에 따라 작업 수행. 룸 리스트 업데이트, 입장하는 방 정보 업데이트
super.onPostExecute(success);
setRoomList(packet.getRoomList());
selectedRoom = packet.getSelectedRoom();
if (success) {
Log.d("SendPacket", "Packet sent successfully!");
setRoomList(packet.getRoomList());
Expand All @@ -183,7 +187,9 @@ protected void onPostExecute(Boolean success) { //doInBackground()의 return값
// NavController를 사용하여 다음 fragment로 이동
navcon.navigate(R.id.navigation_multi_room_wait, bundle);
} else {
showFullRoomToast(mContext); // 방이 이미 꽉 찼다는 Toast 보내기
if(isRoomFull) {
showFullRoomToast(mContext); // 방이 이미 꽉 찼다는 Toast 보내기
}
Log.e("SendPacket", "Failed to send packet!");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ private void showModal(Context context) {
// 초기값 설정
groupNameEditText.setText("Test");
//distanceEditText.setText("5");
time_picker.setHour(0);
time_picker.setMinute(0);
LocalTime now = LocalTime.now().plusMinutes(1);
time_picker.setHour(now.getHour());
time_picker.setMinute(now.getMinute());
membersEditText.setText("5");
numberPickerHour.setValue(0);
numberPickerMinute.setValue(1);
Expand Down
Loading
Loading