-
-
Save cionman/7f83d1fe93c5a1c2b981970368630f3e to your computer and use it in GitHub Desktop.
온라인여부 감지하여 표시
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
/** | |
* 첫번째 탭 유저리스트 호출 | |
*/ | |
FirebaseChat.prototype.loadUserList = function(){ | |
//...생략 | |
var cbCompleteUserList = function(){ | |
this.loadOnlineStatus(); | |
} | |
userRef.orderByChild("userName") | |
.once('value', this.getUserList.bind(this)) | |
.then(cbCompleteUserList.bind(this)); | |
} | |
/** | |
* 유저의 온라인 여부 감지하여 유저리스트에 표시 해주는 기능 | |
*/ | |
FirebaseChat.prototype.loadOnlineStatus = function(){ | |
var usersConnectionRef = this.database.ref('UsersConnection'); | |
usersConnectionRef.off(); | |
var cbUserConnection = function(data){ | |
var connKey =data.key; | |
var connValue = data.val(); | |
var onlineIcon = document.querySelector('#li' + connKey+' .mood'); | |
if(onlineIcon != null){ | |
if(connValue.connection === true){ | |
onlineIcon.classList.remove('hiddendiv'); | |
}else{ | |
onlineIcon.classList.add('hiddendiv'); | |
} | |
} | |
} | |
usersConnectionRef.on('child_added', cbUserConnection.bind(this)); | |
usersConnectionRef.on('child_changed', cbUserConnection.bind(this)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment