* check out what the google quota is, and design accordingly.
* update the front end for all events
* update the backend after no change for 1.0
* for now, changing what they had after the session,
* users reconnecting
* when the socket drop
```javascript
howDidILikeThatSocket.onopen = function open()
{
howDidILikeThatSocket.send
( JSON.stringify
( { "eventID": "newConnection",
"userID" : window.localStorage["howDidILikeThat_userID"] // returning user
}
)
);
};
```
- I added `userID` to the part where you establish a new connection (for a returning user) - so that they get their point data back from server (rather than new data and new ID)
- wouldnt that be SOOOO nice :) I will get on it later
- lol, ok :)
- I think that we need some kind of keepalive, and then if the keepalive fails, we can do a reconnect or w/e. In general, in the domain specific realm, we dont want people to be able to "reconnect" like a week later. but thats just for this specific project
- `setInterval(function(){ howDidILikeThatSocket.send(JSON.stringify({ping: true}))}, 10000);`
- ok, pongs respond to {"eventID":"ping"}
Back now. OK , changed it to {“eventID”:“ping”}
- Let me know when ready to test again (for the update packets)
- everything should be running just now
- Great! Everything is fully working. One thing you could add is to send all the points on a new connection - if not then it's fine, everyone just needs to move their point
- changed my mind. This is fine. I prefer actually people are given the space to be silent until they make their first choice
- also makes more sense that way if it's a one-time realtime usage... :+1: so should be fine i think (like no need for users to keep their ID afterwards I guess)
- domain specific, looks like this:
- userID private personal 1 private personal 2 point x notes x point y
abc Christopher Reay 0.1 Hello x 0.1
abd Jon Doe 0.1 Hello x 0.1
- fields that startWith "private" are ignored by the server. The administrator can connect a person with a userID if they wish. as you say shouldnt be an issue :)
have you seen the spreadsheet? https://docs.google.com/spreadsheets/d/1ibmlbMbwxKP47_8GlLvDnlqOAmw-z6l2DaYpgSnQpyU/edit#gid=0
- no didn't know about that stuff (i just thought it was transitory)
---
https://tauday.com/tau-manifesto
which is more fundamental, $\pi$ or $\tau$?
$\tau = 2 \pi$
$\pi = \frac{\tau}{2}$
- it's using latex syntax... which is fun
- this is very cool
You can also put in center of page:
$$x + 1$$
-----
i think we are complete? so i shall send updated zip with code to john now :+1:
- i think that might do him the world of good :rolling_on_the_floor_laughing:
- haha, yes. OK. See you around Chris! :) .. add me on Telegram if you like: t.me/larcombe
- this hackmd thing is great. i like it
---
TODO:
* socket keepalive
* lets discuss this?
*
* socket reconnect
* lets discuss this later
* here check this out:
* https://docs.google.com/spreadsheets/d/1ibmlbMbwxKP47_8GlLvDnlqOAmw-z6l2DaYpgSnQpyU/edit#gid=0
* its the live spreadsheet holding the data :)
```javascript
// define host url
//************* paste test into browser
var HOSTURL = "dev.christopherreay.com";
// open socket to server
var howDidILikeThatSocket = new WebSocket("wss://"+HOSTURL+"/virtualRoomCollection/howDidILikeThat_socketServer")
// respond to socket opening with with "newConnection" event
howDidILikeThatSocket.onopen = function open()
{
howDidILikeThatSocket.send
( JSON.stringify
( { "eventID": "newConnection"
}
)
);
};
//************** paste test into browser END
// here is an example response
let exampleResponse =
{ "eventID" : "newConnection_response",
"success" : true,
"userID" : "mIEAJL",
"data":
{ "rowNumberInSpreadsheet" : 14,
"userID" : "mIEAJL",
"point x" : 0.0,
"notes x" : "notes x",
"point y" : 0.5,
"notes y" : "notes y",
"point z" : 0.5,
"notes z" : "notes z",
"point a" : 1.0,
"notes a" : "notes a",
"notes general" : "notes general"
}
};
// NOTES:
// it is recommended to store the userID in localStorage to support client reconnection
// ************* paste test into browser
// sending an update of new user values to the server
var randomNumber = Math.random();
howDidILikeThatSocket.send
( JSON.stringify
( { "eventID" : "updateUserData_fromClient",
"data" :
{
// "userID": window.localStorage.getItem("howDidILikeThat_userID"),
"point x": randomNumber,
"notes x": "Hello x "+randomNumber,
"point y": randomNumber,
"notes y": "Hi Y "+randomNumber,
"point z": randomNumber,
"notes z": "Ho z "+randomNumber,
"point a": randomNumber,
"notes a": "red "+randomNumber,
"notes general": "some general notes "+randomNumber,
}
}
)
);
// NOTES:
// it is not necessary to send userID identification with the update, the socket is self identifying
// it is not necessary to send all user information. Just sending changed field values is fine
// *************** paste test into browser END
// receiving an update of new values from the server
let exampleEvent =
{ "eventID" : "updateUserData_fromServer",
"userID" : "mIEAJL",
"data":
{ "rowNumberInSpreadsheet" : 14,
"userID" : "mIEAJL",
"point x" : 0.5,
"notes x" : "notes x",
"point y" : 0.5,
"notes y" : "notes y",
"point z" : 0.5,
"notes z" : "notes z",
"point a" : 0.5,
"notes a" : "notes a",
"notes general" : "notes general"
}
}
// NOTES
// updateUserData_fromServer events always contain the complete set of userData
// it is possible to change this to only send updated fields, if required
// example onmessage code
howDidILikeThatSocket.onmessage =
(incomingMessageJSONString)
{
let messageData = JSON.parse(incomingMessageJSONString.data);
console.log
( { "@: howDidILikeThatSocket.onmessage: messageData": messageData
}
);
if (messageData.eventID === "newConnection_response")
{
window.localStorage.setItem("howDidILikeThat_userID", messageData.userID);
let userDataForNewUser = messageData.data;
// update UI objects
}
else if (messageData.eventID === "updateUserData_fromServer")
{
let userID = messageData.userID;
let updatedUserData = messageData.data;
// update UI objects
}
};
// the code in here requires a keepalive
// we should also look for somewhere to put a socket reconnect
```
* Implementation Discussion
* issues here
* Random Chat :)
*