open menu
//first set up a subscription on events with ID "myUniqueString" gj.event.subscribe("myUniqueString", function(subScribeData){ //use my subScribeData here console.error('User '+ subScribeData.loggedInName+ ' earn so much: ' + gj.utility._prettyAmount(subScribeData.salary)); }); //then it is just for someone to POST a message :) gj.event.post("myUniqueString",{ 'loggedInName' : 'Donald Trumph', 'salary' : 600000000 })
//first set up a RECEIVE function. Note there are no key matching here. The receiver will receive all posted messages // you must distinct what you your action is based on the content of message gj.event.add_message_receive_function(function(subScribeData){ //use my subScribeData here console.error('Received '+subScribeData.id.replace(/_/gi," ")+'\nUser '+ subScribeData.loggedInName+ ' earn this much: ' + gj.utility._prettyAmount(subScribeData.salary)); }); //then it is just for someone to POST a message from window two // the windows must be on the same domain ! gj.event.message_broadcast({ id : 'message_from_window_two', loggedInName : 'Donald Duck', salary : 60 }); //then it is just for someone to POST a message from window three:) gj.event.message_broadcast({ id : 'message_from_window_three', loggedInName : 'Bill Gates', salary : 80000000 });