Skip to content

Commit

Permalink
read reciept added, partially working
Browse files Browse the repository at this point in the history
  • Loading branch information
ChauhanAbhinav committed Aug 20, 2019
1 parent d2f34ee commit 1d2f0fe
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
6 changes: 5 additions & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ io_private.on('connection', function(socket){
socket.user1 = userData[0];
socket.room = userData[1];
private_rooms[socket.room] = socket.room;
console.log(private_rooms);
// console.log(private_rooms);
socket.join(socket.room);
// console.log(usernames);

Expand All @@ -81,6 +81,10 @@ socket.on('sendchat', function (data) {
io_private.to(socket.room).emit('updatechat', socket.user1, data);
});

socket.on('sendVisibility', function(vis){
console.log(vis);
socket.broadcast.to(socket.room).emit('getVisibility', vis)
})
socket.on('disconnect', function(){
socket.broadcast.to(socket.room).emit('server','<i>' + socket.user2 + '</i> has left the room');
socket.leave(socket.room);
Expand Down
20 changes: 10 additions & 10 deletions server/twilio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ auth.sendAuthyToken = function(user, successCallback, errorCallback) {
function(err, response) {
if (err || !response.user) return errorCallback(err);
user.authyId = response.user.id;
// successCallback(response, user.authyId); // FOR TESTING PURPOSE
sendToken();
successCallback(response, user.authyId); // FOR TESTING PURPOSE
// sendToken();
});
} else {
// Otherwise send token to a known user
console.log('registered authy user found');
// successCallback(response, user.authyId); // FOR TESTING PURPOSE
sendToken();
successCallback(response, user.authyId); // FOR TESTING PURPOSE
// sendToken();
}

// With a valid Authy ID, send the 2FA token for this user
Expand All @@ -36,15 +36,15 @@ auth.sendAuthyToken = function(user, successCallback, errorCallback) {

// Test a 2FA token
auth.verifyAuthyToken = function(authyId, token, cb) {
// let response={};
// response.message = "token is valid";
let response={};
response.message = "token is valid";
// let error={};
// error.message = "token is invalid";
// cb(null, response);
cb(null, response);

authy.verify(authyId, token, function(error, response) {
cb(error, response);
});
// authy.verify(authyId, token, function(error, response) {
// cb(error, response);
// });
};

// Send a text message via twilio to this user
Expand Down
30 changes: 25 additions & 5 deletions src/assets/socket.io/client/private-socket.io.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,33 @@ socket.on('connect', function(){
socket.emit('createRoom', userData);
});

socket.on('updatechat', function (username, data) {
$('#conversation').append('<li><b>'+username + ':</b> ' + data + '<br></li>');

if(vis()){
socket.on('getVisibility', function(read){
updateRead(read);
});

let updateRead = function(read) {
// alert(read);
if(read) {
$('#read').html("Read &#10004;");}
else{
$('#read').html("")
}

}

socket.on('updatechat', function (username, data) {
$('#conversation').append('<li><b>'+username + ':</b> ' + data + '<br></li>');

if(username == user) {
// alert('if');
}
else {
// alert('else')
socket.emit('sendVisibility', vis());
$('#read').html("");
}
});


socket.on('server',function(msg){
$('#conversation').append('<li> <b>Server: </b>'+msg+'</li>');
});
Expand Down Expand Up @@ -65,6 +81,10 @@ var vis = (function(){
vis(function(){
if(vis()){
console.log('visible now');
// setTimeout(function(){
// console.log('visible now');
// alert();
// }, 5000)
}
});

0 comments on commit 1d2f0fe

Please sign in to comment.