in the main app:
//aws config
AWS.config.loadFromPath('credentials.json');
AWS.config.update({region: 'us-east-1', apiVersion: '2009-04-15'});
exports.AWS = AWS;
in the views/partials/partial1.jade:
p IC Name: {{character.Attributes["IC Name"]}}
in public/js/controllers.js:
socket.on('send:character', function (data) {
$scope.character = data.character;
in routes/socket.js:
var AWS = require('aws-sdk');
var sendChar = function(socket) {
console.log("send character");
var sdb = new AWS.SimpleDB();
var params = {
'DomainName': 'Avatars',
'ItemName': 'Avatar Name'
};
sdb.getAttributes(params,function(err, data){
if(err) {
console.log('error in send:character: ',err);
return error;
}
charData = {'Attributes':{}};
data.Attributes.forEach(function(value,index){
charData.Attributes[value.Name]=value.Value;
});
console.log('char data returned: ',charData);
socket.emit('send:character', {
character: charData
});
});
}
module.exports = function (socket) {
...
sendChar(socket);
...
};
No comments:
Post a Comment