diff --git a/app/src/main/java/com/example/tampopo_client/viewmodels/ChatViewModel.java b/app/src/main/java/com/example/tampopo_client/viewmodels/ChatViewModel.java index 1cf6c18..1b360d7 100644 --- a/app/src/main/java/com/example/tampopo_client/viewmodels/ChatViewModel.java +++ b/app/src/main/java/com/example/tampopo_client/viewmodels/ChatViewModel.java @@ -57,7 +57,7 @@ this.chatroomResource = retrofit.create(ChatroomResource.class); } - public ChatViewModel(String userId, String token,String chatroomId) { + public ChatViewModel(String userId, String token, String chatroomId) { this.userId = userId; this.token = token; this.chatroomId = chatroomId; @@ -81,19 +81,36 @@ notificationListeners.forEach(NotificationListener::onNotificationReceived); }, 10_000); // 10秒後に通知 } - foundChatroom(userId); + foundChatroom(userId,token); loadLatestMessage(chatroomId, userId, token); }; } // getter - public MutableLiveData getChatroomIdLiveData() { return chatroomIdLiveData; } - public MutableLiveData> getChatMessages() { return chatMessages; } - public MutableLiveData getLatestMessageLiveData() { return latestMessage; } - public MutableLiveData getChatroomClosed() { return chatroomClosed; } - public MutableLiveData getChatFriendToMeLiveData() { return chatFriendToMeLiveData; } - public MutableLiveData getChatToFriendLiveData() { return chatToFriendLiveData; } + public MutableLiveData getChatroomIdLiveData() { + return chatroomIdLiveData; + } + + public MutableLiveData> getChatMessages() { + return chatMessages; + } + + public MutableLiveData getLatestMessageLiveData() { + return latestMessage; + } + + public MutableLiveData getChatroomClosed() { + return chatroomClosed; + } + + public MutableLiveData getChatFriendToMeLiveData() { + return chatFriendToMeLiveData; + } + + public MutableLiveData getChatToFriendLiveData() { + return chatToFriendLiveData; + } // =============================== // 1. チャットルームに入る(かける側) @@ -117,8 +134,8 @@ } // 1.5 自分がchatroomに入っているのか確認する - public void foundChatroom(String userId) { - Call call = chatroomResource.getMyChatroom(userId); + public void foundChatroom(String userId, String token) { + Call call = chatroomResource.getMyChatroom(userId, token); call.enqueue(new Callback() { @Override public void onResponse(Call call, Response response) { @@ -144,7 +161,7 @@ // 1.55 現在通話中のペアを確認 // =============================== public void fetchActiveChatPair(String userId, String token) { - Call call = chatroomResource.getMyChatroom(userId); + Call call = chatroomResource.getMyChatroom(userId, token); call.enqueue(new Callback() { @Override public void onResponse(Call call, Response response) { @@ -247,6 +264,7 @@ } // ===== ここから Handlerループ部分をそのまま追記 ===== + /** * 10秒ごとにサーバー確認を行う */ @@ -277,3 +295,4 @@ isChecking = false; } } +// \ No newline at end of file