Skip to content

Commit

Permalink
match making exit button fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuffugurlu committed Apr 23, 2024
1 parent e76a7a7 commit 43faf78
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions API/Apps/Game/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def disconnect(self, close_code):
self.channel_name,
)

def receive(self, text_data=None, bytes_data=None):
text_data_json = json.loads(text_data)
if text_data_json['request_type'] == 'disconnect':
self.close()

def match_making_message(self, event):
self.send(text_data=json.dumps({
'message': event['message'],
Expand Down
2 changes: 1 addition & 1 deletion Backend/static/public/inbox.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Backend/static/public/logout.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions Backend/static/scripts/matchmaking.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,17 @@ async function connectToSocket() {
handleTimer();
}
socket.onmessage = async (event) => {
const data = JSON.parse(event.data);
const data = JSON.parse(event.data);
clearInterval(interval)
await matchFounded()
loadPage(`/game/${data.game_id}`);
loadPage(`/game/${data.game_id}`);
}
document.getElementById("close-matchmaking").addEventListener('click', () => {
socket.send(JSON.stringify({
request_type: "disconnect",
}))
loadPage('/home/')
})
}
async function App() {
await connectToSocket();
Expand Down

0 comments on commit 43faf78

Please sign in to comment.