Skip to content

Commit 5ed5588

Browse files
committed
For #1: rename loggedIn event, createNewGist function
- loggedIn --> userLogin - createNewGist --> handleCreateNewGist
1 parent a8fe678 commit 5ed5588

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

public/local.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ editor.getSession().setMode('ace/mode/javascript');
9191
EVENT NAMES: CLIENT FUNCTIONS:
9292
- connection Send: SocketIO built-in event
9393
- disconnect Send: SocketIO built-in event
94-
- loggedIn Send: handleUserLogin
94+
- userLogin Send: handleUserLogin
9595
- editorTextChange Send: handleLocalEditorTextChange
9696
Receive: handleServerEditorTextChange
9797
- playerListChange Receive: handlePlayerListChange
@@ -101,7 +101,7 @@ editor.getSession().setMode('ace/mode/javascript');
101101
Receive: handleServerEditorCursorChange
102102
- editorScrollChange Send: handleLocalEditorScrollChange
103103
Receive: handleServerEditorScrollChange
104-
- createNewGist Receive: createNewGist
104+
- createNewGist Receive: handleCreateNewGist
105105
- newGistLink Receive: handleNewGistLink
106106
Send: (sent after creating or forking)
107107
-------------------------------------------------------------- */
@@ -135,7 +135,7 @@ function handleUserLogin (userData) {
135135
updateLoggedInView(userData.login, userData.avatar_url);
136136

137137
// Notify server that user logged in
138-
socket.emit('loggedIn', {login: userData.login, avatar_url: userData.avatar_url});
138+
socket.emit('userLogin', {login: userData.login, avatar_url: userData.avatar_url});
139139
}
140140

141141
// Send editorInputView data to server
@@ -211,7 +211,7 @@ socket.on('editorScrollChange', handleServerEditorScrollChange);
211211
socket.on('playerListChange', handlePlayerListChange);
212212
socket.on('updateState', handleUpdateState);
213213
socket.on('turnChange', handleTurnChange);
214-
socket.on('createNewGist', createNewGist);
214+
socket.on('createNewGist', handleCreateNewGist);
215215
socket.on('newGistLink', handleNewGistLink);
216216

217217
// When receiving new editorInputView data from server
@@ -531,8 +531,8 @@ function updateCurrentGistView (gistData) {
531531
GITHUB API FUNCTIONS
532532
---------------------------------------------------- */
533533
// Make a POST request via AJAX to create a Gist for the current user
534-
function createNewGist() {
535-
console.log('called createNewGist at ' + new Date().toString().substring(16,25), 'color: red; font-weight: bold;');
534+
function handleCreateNewGist() {
535+
console.log('called handleCreateNewGist at ' + new Date().toString().substring(16,25), 'color: red; font-weight: bold;');
536536
// use currentAccessToken
537537
// use https://developer.github.com/v3/gists/#create-a-gist
538538

@@ -551,7 +551,7 @@ function createNewGist() {
551551

552552
postWithGitHubToken('https://api.github.com/gists', gistObject).then(function(responseText){
553553
//console.log(responseText);
554-
console.log('createNewGist: response received at ' + new Date().toString().substring(16,25), 'color: red; font-weight: bold;');
554+
console.log('handleCreateNewGist: response received at ' + new Date().toString().substring(16,25), 'color: red; font-weight: bold;');
555555
console.dir(gistObject);
556556

557557
var gistObject = JSON.parse(responseText);

server.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ server.listen(port, function() {
6666

6767
/* ------------------------------------------------------------
6868
EVENT NAMES: SERVER FUNCTIONS:
69-
- loggedIn io.emit: playerListChange
69+
- userLogin io.emit: playerListChange
7070
socket.emit: editorTextChange, editorScrollChange, editorCursorChange, turnChange
7171
- disconnect Broadcast: playerListChange
7272
- editorTextChange Broadcast: editorTextChange
@@ -102,7 +102,7 @@ io.on('connection', function (socket) {
102102
//console.log('\t\t playerList.length: ' + playerList.length);
103103

104104
// When a user logs in,
105-
socket.on('loggedIn', function (userData) {
105+
socket.on('userLogin', function (userData) {
106106
console.log('\n* * * * # # # # User logged in! # # # # * * * * *');
107107
console.log('\t\t > > > ' + userData.login + ' < < <\n');
108108
//console.log('\t\t playerList.length: ' + playerList.length);
@@ -137,7 +137,7 @@ io.on('connection', function (socket) {
137137
// Broadcast updated playerList to ALL clients
138138
io.emit('playerListChange', playerData);
139139

140-
console.log('\non("loggedIn") -- turnData broadcasted!\n');
140+
console.log('\non("userLogin") -- turnData broadcasted!\n');
141141
//console.log( getTurnData() );
142142

143143
//console.log(' ! ! ! ! ! ! player data and list ! ! ! ! ! !');

0 commit comments

Comments
 (0)