-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/* | ||
orchesta.sublime-workspace |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: node index.js |
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) |
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; | ||
} | ||
|
||
|
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"); | ||
} |
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); | ||
} | ||
|