happychat-service
Advanced tools
Comparing version 0.8.1 to 0.8.2
@@ -37,2 +37,3 @@ 'use strict'; | ||
var meta = _ref.meta; | ||
var type = _ref.type; | ||
return { | ||
@@ -43,2 +44,3 @@ id: id, timestamp: timestamp, text: text, | ||
author_type: author_type, | ||
type: type, | ||
meta: meta | ||
@@ -171,2 +173,11 @@ }; | ||
customers.on('typing', function (chat, user, text) { | ||
operators.emit('receive.typing', chat, user, text); | ||
}); | ||
operators.on('typing', function (chat, user, text) { | ||
operators.emit('receive.typing', chat, user, text); | ||
customers.emit('receive.typing', chat, user, text); | ||
}); | ||
customers.on('message', function (chat, message) { | ||
@@ -173,0 +184,0 @@ // broadcast the message to |
@@ -59,2 +59,7 @@ 'use strict'; | ||
socket.on('typing', function (text) { | ||
debug('received customer typing', user.id, text); | ||
events.emit('typing', chat, user, text); | ||
}); | ||
socket.on('disconnect', function () { | ||
@@ -95,2 +100,9 @@ return events.emit('leave', socketIdentifier); | ||
}); | ||
events.on('receive.typing', function (chat, user, text) { | ||
// customers shouldn't know who is typing or what they're typing | ||
var isTyping = typeof text === 'string' && text.length > 0 ? true : false; | ||
io.to(chatRoom(chat)).emit('typing', isTyping); | ||
}); | ||
io.on('connection', function (socket) { | ||
@@ -97,0 +109,0 @@ debug('customer connecting'); |
@@ -76,2 +76,6 @@ 'use strict'; | ||
var customerRoom = function customerRoom(id) { | ||
return 'customers/' + id; | ||
}; | ||
var queryClients = function queryClients(io, room) { | ||
@@ -262,2 +266,9 @@ return new Promise(function (resolve, reject) { | ||
socket.on('chat.typing', function (chat_id, text) { | ||
var userIdentity = identityForUser(user); | ||
debug('received operator `typing` event', userIdentity.id, chat_id, text); | ||
events.emit('typing', { id: chat_id }, userIdentity, text); | ||
}); | ||
socket.on('chat.join', function (chat_id) { | ||
@@ -414,6 +425,11 @@ debug('client requesting to join', chat_id); | ||
var room_name = 'customers/' + id; | ||
io.in(room_name).emit('chat.message', { id: id }, message); | ||
io.in(customerRoom(id)).emit('chat.message', { id: id }, message); | ||
}); | ||
events.on('receive.typing', function (chat, user, text) { | ||
var id = chat.id; | ||
io.in(customerRoom(id)).emit('chat.typing', chat, user, text); | ||
}); | ||
events.on('status', function (user, status) { | ||
@@ -420,0 +436,0 @@ store.dispatch((0, _store.updateUserStatus)(user, status)); |
{ | ||
"name": "happychat-service", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"description": "Socket.IO based chat server for happychat.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
54460
1400