Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mfontanadev committed Mar 11, 2016
0 parents commit 8cf712d
Show file tree
Hide file tree
Showing 88 changed files with 19,027 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/*
orchesta.sublime-workspace
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/libraries/orchesta_node_modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/orchesta.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/scopes/scope_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

695 changes: 695 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: node index.js
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## This is an Orchesta simulator, it was created to learn about node-js, socket-io and heroku.
Explanation in few words, the app let you join to a virtual orchesta, you phone or your pc will plays the instrument sounds.

Enjoy at: https://orchesta.herokuapp.com/

## Documentation

For more information about using Node.js on Heroku, see these Dev Center articles:

- [Getting Started with Node.js on Heroku](https://devcenter.heroku.com/articles/getting-started-with-nodejs)
- [Heroku Node.js Support](https://devcenter.heroku.com/articles/nodejs-support)
- [Node.js on Heroku](https://devcenter.heroku.com/categories/nodejs)
- [Best Practices for Node.js Development](https://devcenter.heroku.com/articles/node-best-practices)
- [Using WebSockets on Heroku with Node.js](https://devcenter.heroku.com/articles/node-websockets)
38 changes: 38 additions & 0 deletions config/globalDefinitions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
var C_APPLICATION_TITLE_AND_VERSION = 'Orchesta (v1.0.0)';
var C_REDIRECT_HEROKU_ADDRESS = '192.168.34.137:5000';

// Definition of states for the machine of finite states used in app main loop.
function MainLoopState()
{
}

MainLoopState.C_APP_STATE_INTRO = 1;
MainLoopState.C_APP_STATE_WAITING_USER_NAME = 2;
MainLoopState.C_APP_STATE_INSTRUMENT_SELECTION = 3;
MainLoopState.C_APP_STATE_SCORE = 4;
MainLoopState.C_LOCAL_STORE_NAMESPACE = "orchesta";

// All sounds used by de app. SoundManager will preload all of them.
var global_sound_definition = [
];

// All bitmaps used by de app. ResourceManager will preload all of them.
var global_image_definition =
[
'glif-left-arrow.png',
'glif-right-arrow.png',
'glif-down-arrow.png',
'glif-sub.png',
'glif-add.png',
'ctree_root.png',
'ctree_root2.png',
'ctree_branch.png',
'ctree_leave.png'
];

if (typeof module !== 'undefined' && module !== null)
{
module.exports = MainLoopState;
}


7 changes: 7 additions & 0 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = function(app)
{
app.get ('/config/globalDefinitions.js',
function (req, res) {res.sendFile(__dirname + '/globalDefinitions.js');});

console.log(" config/index.js: OK");
}
136 changes: 136 additions & 0 deletions controllers/entities/chatInterpeter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
var currentUserName = "";

var messages = [];
var socket = null;
var sendButton = null;
var name = null;
var startButton = null;
var owner = null;

function initChat()
{
owner = this;

var myHost = window.location.hostname;

if (myHost == "localhost")
myHost = myHost + ":5000";
else if (myHost.substring(0,7) == "192.168")
myHost = myHost + ":5000";

console.log("HOST HOST HOST:" +myHost);

socket = io.connect(myHost);

//***remover
sendButton = document.getElementById("send");
startButton = document.getElementById("idStartButton");

socket.on
(
'message',
function (data)
{
if(data.message)
{
console.log("");
console.log("CLIENT:")
console.log("data");
console.log("");
console.log("<--- Incomming CLIENT data: " + JSON.stringify(data));

if (data.message == "WELCOME")
{
socket.emit('send', { message: Protocol_Messages.C_MESSAGE_GET_INSTRUMENTS_string, sender: "CLIENT", receptor:'server', params: '', data:'' });
}

if (data.message == Protocol_Messages.C_MESSAGE_GET_INSTRUMENTS_string)
{
console.log(Protocol_Messages.C_MESSAGE_GET_INSTRUMENTS_string);
//console.log('data=' + data);
//console.log('data JSON=' + JSON.stringify(data));
owner.onFillInstruments(data.data);
}

if (data.message == Protocol_Messages.C_MESSAGE_SELECTED_INSTRUMENT_string)
{
// Get score
socket.emit
('send',
{
message: Protocol_Messages.C_MESSAGE_GET_SCORE_string,
sender: currentUserName,
receptor: 'server',
params: data.params,
data:''
}
);
}

if (data.message == Protocol_Messages.C_MESSAGE_GET_SCORE_string)
{
owner.onGetScore(data);
}

if (data.message == Protocol_Messages.C_MESSAGE_PLAY_INSTRUMENTS_string)
{
owner.onScoreStart();
}

if (data.message == Protocol_Messages.C_MESSAGE_PAUSE_INSTRUMENTS_string)
{
owner.onScorePause();
}

if (data.message == Protocol_Messages.C_MESSAGE_STOP_INSTRUMENTS_string)
{
owner.onScoreReset();
}

if (data.message == Protocol_Messages.C_MESSAGE_VOLUME_ON_string)
{
owner.btnSoundOn_controller();
}

if (data.message == Protocol_Messages.C_MESSAGE_VOLUME_OFF_string)
{
owner.btnSoundOff_controller();
}
}
else
{
console.log("There is a problem:", data);
}
}
);
}

function send_button_message(_senderName, _text)
{
socket.emit('send', { message: _text, username: _senderName });
}

function send_selected_instrument_base(_idInstrument, _multiEditorIndex, _scoreId)
{
socket.emit
(
'send',
{ message: Protocol_Messages.C_MESSAGE_SELECTED_INSTRUMENT_string,
sender: currentUserName,
receptor:'server',
params: {scoreId: _scoreId, instrumentId: _idInstrument, multiEditorIndex: _multiEditorIndex},
data:''
}
);
}

function send_selected_instrument(_idInstrument)
{
send_selected_instrument_base(_idInstrument, 0, 1);
}

function send_selected_instrument_multieditorIndex(_idInstrument, _multiEditorIndex)
{
send_selected_instrument_base(_idInstrument, _multiEditorIndex, 1);
}

Loading

0 comments on commit 8cf712d

Please sign in to comment.