help-fem
Version:
A Browserify/Node.js client module for the Help.com team's FEM.
57 lines (50 loc) • 1.49 kB
JavaScript
;(function() {
// Import HelpFem. (Will be on NPM soon.)
var HelpFem = require('../../../help-fem.js');
// Extend the client like in Ampersand.
var FemClient = HelpFem.Client.extend({
// Define socket events similarly.
events: {
// You can override built-in events.
'server session event': {
// You can also override specific event types without
// affecting the other defaults.
'logout': 'sessionLogout'
}
},
sessionLogout: function(error, response) {
console.log('Overwriting the login success: ' + JSON.stringify(response));
}
});
// Instantiate your extended client.
var femClient = new FemClient({
uri: 'http://54.165.155.54:8080', // Replace with your uri.
organizationId: '2b9ad7bd-3aba-407c-83ce-9e95581a11bf'
});
console.log(window.role);
if (window.role === 'customer') {
// Login
femClient.session.login({
email: 'fred@smith.com',
role: 'customer'
});
setTimeout(function() {
femClient.chat.start();
}, 1000);
} else {
femClient.session.login({
email: 'alex@suitupalex.com',
password: 'test',
role: 'user'
});
setTimeout(function() {
femClient.chat.getActiveUsers();
}, 1000);
setTimeout(function() {
femClient.chat.requestTransfer({
userId: '3cf8793e-4ed1-4320-82a7-34980054c5c1',
customerId: 'FAKE-cde8c58a-e9fb-4cdb-941d-c251e3f87f5c'
});
}, 10000);
}
})();