Skip to content

Commit

Permalink
Removed localhost url from websockets. Added check for browsers which…
Browse files Browse the repository at this point in the history
… don't support Storage!
  • Loading branch information
Saheb committed Sep 18, 2015
1 parent ea8ec0b commit 6240115
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/views/home.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
<link href="@routes.Assets.at("stylesheets/starter-template.css")" rel="stylesheet">

<script>
if(typeof(Storage) !== "undefined") {
// Code for localStorage/sessionStorage.
console.log("Your browser has Storage! Game will work!");
} else {
// Sorry! No Web Storage support..
console.log("Your browser doesn't have Web Storage! Game will not work!");
alert("Your browser doesn't have Web Storage! Game will not work!");
}
var store = window.sessionStorage
function checkLogin() {
if(store.length!=0)
Expand Down
1 change: 0 additions & 1 deletion public/loginCalls.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ startApp()
//attachSignin(document.getElementById('google-login-btn'));

function attachSignin(element) {
console.log(element.id);
auth2.attachClickHandler(element, {},
function(googleUser) {
document.getElementById('loginName').innerText =
Expand Down
10 changes: 9 additions & 1 deletion public/sockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ store.setItem("turn_number", "NA")
//store.setItem("round_number", "0")

var player_id = Number(store.getItem("loginId"))
var ws = new WebSocket("ws://localhost:9000/gamePlay/"+ GAME_ID + "/" + player_id + "/play")
var loc = window.location, new_uri;
if (loc.protocol === "https:") {
new_uri = "wss:";
} else {
new_uri = "ws:";
}
new_uri += "//" + loc.host;
//new_uri += loc.pathname;
var ws = new WebSocket(new_uri + "/gamePlay/"+ GAME_ID + "/" + player_id + "/play")
ws.onopen = function()
{
// Web Socket is connected, send data using send()
Expand Down

0 comments on commit 6240115

Please sign in to comment.