Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Display error message on attempt to join invalid socket room
Browse files Browse the repository at this point in the history
  • Loading branch information
m7kvqbe1 committed May 18, 2015
1 parent e9cfac0 commit f1e0348
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
26 changes: 21 additions & 5 deletions src/application/components/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,21 @@ var UserInterface = {
}
},

showRoomId: function(roomid) {
$('#room-id > span').text(roomid);
showRoomId: function(roomid, err) {
if(err) {
$('#room-id').html('Room ID Invalid');

setTimeout(function() {
if(WebSocket.room) {
$('#room-id').html('<strong>Current Room ID:</strong><br /><span>' + WebSocket.room + '</span>');
} else {
$('#room-id').html('');
}
}, 4000);
} else {
$('#room-id').html('<strong>Current Room ID:</strong><br /><span>' + roomid + '</span>');
}

$('#room-id').removeClass('hidden');
},

Expand Down Expand Up @@ -96,13 +109,16 @@ var UserInterface = {
break;

case 'join':
var guid = $('#prompt input').val();
var uuid = $('#prompt input').val();

if(guid === '') return;
if(!/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i.test(uuid)) {
this.showRoomId(null, true);
return;
}

if(WebSocket.room) WebSocket.leaveRoom();

WebSocket.joinRoom(guid);
WebSocket.joinRoom(uuid);
break;

default:
Expand Down
5 changes: 1 addition & 4 deletions src/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@
</ul>
</nav>

<div id="room-id" class="hidden animated bounceInRight">
<strong>Current Room ID:</strong><br />
<span></span>
</div>
<div id="room-id" class="hidden animated bounceInRight"></div>

<div class="shortcuts unselectable animated bounceInLeft">
<img src="/public/svg/keyboard.svg" width="40px" />
Expand Down

0 comments on commit f1e0348

Please sign in to comment.