How can I play a sound when my meteor server restarts? - meteor

I have only one monitor and I find it hard keeping track of all the windows, and on top of that, I have a slow PC.
I am usually at my text editor, not seeing if the changes were loaded by Meteor.js. Is there anyway to play a sound when my meteor server restarts because of changes?
Bonus points: a different sound when there's an error preventing the startup.
Edit: I'm using Windows 7, but I'd also want to know how to do it on Mac and Linux.

You can use node for this:
meteor add meteorhacks:npm
Then run your project with meteor to create the packages.json file in your root directory
Add the below to the package.json so it looks something like this:
{
"play": "0.5.0"
}
Create a file on your desktop, a sound, e.g sound.wav
And play it on startup: (server side code):
Meteor.startup(function() {
var play = Meteor.npmRequire('play').Play();
// play with a callback
play.sound('~/Desktop/sound.wav', function() { });
//If you want to know when the player has defintely started playing
play.on('play', function (valid) {
console.log('I just started playing!');
});
//If you want to know if this can't play for some reason
play.on('error', function () {
console.log('I can't play!');
});
});
It should work on mac and windows too, just make sure you use the correct path, you may be better off with an absolute path to the file C:\Users....wav
You will need one of the following cli players to play the sound:
afplay
mplayer (Easiest installed on os x with brew install mplayer, on windows this may help: http://www.mplayerhq.hu/DOCS/HTML/en/windows.html)
mpg123
mpg321
play
You can install any, so long as the platform can run one it should be ok.. If you download the raw binary for any of them be sure to add the directory the executables are in to your PATH environment variable.

Related

Firebase doesn't show connected user

I'm learning to work with Firebase within Unity.
1. What I've done so far -
1.1 Created a Firebase and Unity project
1.2 copied the json file into Assets folder
1.3 imported Firebase packages
1.4 downloaded jdk-8 and created JAVA_HOME variable
1.5 Created a c# script and put it into a gameobject (from the Firebase tutorial)
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => {
FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
});
1.6 switched to Android environment and built with result "SUCCESSFUL" - with no errors whatsoever.
2. The issue -
2.1 I logged into my project on firebase and ran the code (from pc on Unity) and on my Android device, but firebase doesn't show any users connected :( (waiting for analytics).
2.2 Firebase
What am I doing wrong?
The app actually works! It just doesn't show connected users.
I went straight ahead and started logging data to the Real Time Data Base and it worked - data was added but it keeps saying "0 User Connections".
Is that a bug?
The first thing to do is double check that the task completed successfully. You can do this by saying:
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => {
if (task.Exception != null) {
Debug.LogError($"Task failed with {task.Exception}");
}
else if (task.Result != DependencyStatus.Available) {
Debug.LogError($"Firebase dependencies not available with {task.Result}");
}
else {
Debug.Log("Everything's good!");
FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
}
});
You'll want some way to listen to these messages on device, and you can sometimes get the Unity Console to track those. But these days I like to install the Android Logcat plugin. You can find it in the Package Manager built into Unity:
It'll give you this cool window under Window/Analysis/Android Logcat:
And usually automatically hooks up to any game I run with the "Build & Run" button in Unity.
This will give you a ton of useful information about your game and perhaps shed a little more light on what's going on if you either hadn't been seeing the Unity logs or had been running adb logcat from the command line.
If you don't see any helpful logs there, there's a button in that logcat window called "Open Terminal". The claim is that it will open a terminal with adb in the $PATH so you can run android commands (in my own testing, the window appeared behind Unity, so I didn't think it was working. Then using which adb it still showed my system install of adb.).
With this open, follow the instructions for debugging analytics on Android. You'll want to type adb shell setprop debug.firebase.analytics.app <package_name> where <package_name> would be whatever your game's package name is (in my screenshot above, it's com.Firebase.PopsiclePlatformer).
Then you can open "Debug View" in the Firebase Console and see events in near real time:
I didn't include these steps in my video because it was difficult to embed both iOS and Android instructions in a timely manner, it should typically just work although Analytics doesn't guarantee realtime event reporting, and the focus wasn't on Analytics. I'm looking at making an updated thing just for Analytics, so I'm really curious if all of this helps you!
There are a couple of other things to check:
You might want to make sure you hooked up Google Analytics (this wasn't a thing when I recorded my video), but I don't think you could get the linked screenshot if you did.
You may also have to run "Force Resolve" from the External Dependency Manager, but that will be much more obvious if you have good logging going:
--Patrick

Meteor android build version

I have a strange issue. I build my Meteor app and run it on android device using -
meteor run android-device --mobile-server=<my_aws_ip>:3000
When the app deploys immediately it connects to the server (and my javascripts etc works). After a few seconds, the page refreshs and none of the javascript callbacks work. Please help me debug this issue.
More information: If I change the client (and not the server), and deploy it, for the first few seconds, the changed client gets shown on the phone. After the first few seconds, the version which is present on the server is shown. So I think Cordova or Meteor is trying to fetch the client code from the server, which is breaking the app. Is there a way to prevent this behavior?
Even more data points -
My aws code does NOT have android and ios platforms installed. Because of this, I think the cordova plugins are not installed, causing a JS break somewhere.
Easiest fix I can think of is remove cordova autoupdate. This is being added by meteor-platform package. If I clone meteor-platform and comment out the cordova autoupdate, the app doesn't load.
Is there another way of removing autoupdate?
This sounds like you have a different version of your app deployed at the mobile-server address.
The local code is run in development mode. Your AWS one is likely in production mode (and may contain a syntax error).
When you run your app it sees the code is different and fetches the new/old (different) version with a hot code reload - hence the page refresh/flash.
To fix this, you need to find the syntax error in your code. It's best to view the ADB logger or run with meteor run --verbose android-device ....
This will provide a bit more information such as an Uncaught exception: cannot read .. of null error type error.
It's hard to say what the error is. The error prevents the rest of your code from executing. In production mode the entire project is one JS file. If there is an error of any kind half way along the file, the rest of the file will not execute.
Also, try loading <my_aws_ip>:3000 in your browser and watch for JS errors in the JS console.
You can also run it locally with --production to simulate a production build environment locally.
Enabling autoupdate but without a page refresh:
Reload._reload = function (options) {
console.log("Next load will load new version");
};

Dart Pirate Tutorial Doesn't Download JSON after build (step 7)

I did the Google Dart tutorial (pirate name badge: https://www.dartlang.org/codelabs/darrrt/) all the way through and it ran exactly as expected until I hit step 7 where I run the build on my normal browser.
What happens is the page loads, but it never seems to complete the async download of the JSON file, so the input and button never become enabled and Chrome keeps spinning because it's waiting on localhost (127.0.0.1).
I imagine this is because I'm not running a web server?
What would I have to do to get this sample app to run on my local machine?
Thanks!
Browser: Chrome 42.0.2311.90
OS: Mac OS X 10.10.3
Why are you not running a web server? You could just run pub serve web from the package folder (where the pubspec.yaml file is) and load the page from http://localhost:8080/piratebadge.html.
Your <Dart-SDK>/bin directory needs to be added to your systems PATH in order to make pub serve web work.
If you use DartEditor just use the run context menu on the piratebadge.html file and it launches pub serve automatically.
This appears to be a new bug in the DartEditor on Mac (and Linux), see https://code.google.com/p/dart/issues/detail?id=23431&thanks=23431&ts=1431391466
One way to work around this is to start your own http server, e.g. 'python -m SimpleHTTPServer' in the build/web directory and then goto http://localhost:8000/piratebadge.html.

Starting Meteor with Velocity test without the Chrome pop-up

In my quest to gather knowledge about how to use Velocity, I ran across a snippet that mentioned a shell variable to set the browser Velocity used to run Karma in PhantomJS as apposed to creating a Chrome window pop-up each time I run my app in DEV-mode. At the time I shrugged it off, but after having implemented some testing in two of my apps, I can say it's an annoying pain to have the tests running in a pop-up window.
Does someone know if how one might get the tests running such that they run in PhantomJS and not in a Chrome pop-up windows? I thought the variable was something like VELOCITY_BROWSER=PhantomJS, but that doesn't seem to work. Also, is there a way to setup Meteor so that it simply sets this as a default so I don't have to create the variable each time, like in a config or something?
I found the answer for those that find this and were also wondering how to prevent the Karma popup.
I am using the sanjo:jasmine test suite, which uses Karma for the client integration tests. You can set the default browser to PhantomJS by simply adding this to your environment when you run meteor:
JASMINE_BROWSER=PhantomJS
Or, if you just want to turn off client integration tests altogether simply adding this:
JASMINE_CLIENT_UNIT=0
So, for instance you can run your app like JASMINE_BROWSER=PhantomJS meteor, and you will not get the popup any longer. What I did was created a meteor.sh in my app root folder that I use to launch with environment variables like so:
#!/bin/sh
JASMINE_BROWSER=PhantomJS meteor
This is only for convenience so I wouldn't have to remember the variable to do this. This should work on any *nix-based OS. You could also make an alias if you wanted. It would look something like:
alias meteor=JASMINE_BROWSER=PhantomJS meteor
I may be slightly off in the syntax, but I think that should work.
To use PhantomJS you do need to have it installed, so run this in a terminal:
npm install -g phantomjs
Or, if you are on a Mac run (you will need brew installed):
brew install phantomjs
Hope this helps someone in the future.
In sanjo:jasmine 0.17.0 on Windows, PhantomJS has some issues with meteor's autoupdate feature. You may have problems with re-running tests when you change the app's code.
If you'd like to stick with Chrome window, it can be somewhat hid by using chrome's commandline options, but you'd need to update karma-chrome-launcher\index.js to include these:
return [
'--user-data-dir=' + this._tempDir,
'--no-default-browser-check',
'--no-first-run',
'--disable-default-apps',
'--disable-popup-blocking',
'--disable-translate',
'--window-position=-800,0', // <-- added
'--window-size=800,600' // <-- added
].concat(flags, [url])
The window will show up, but will be created off-screen, and somehow luckily doesn't even steal the keyboard focus.

Using Nokia Qt to send message in S60 (Nokia E72)

I am new to Qt, and trying to use QtMobility to send message. I am using example in this link:
http://doc.qt.nokia.com/qtmobility/writemessage.html
I am able to compile the source code, and it can be tested on the simulator. But when I deploy it to E72, the program failed. Because it can't found any available accounts. The problem lies in this code:
// Find the list of available accounts and add them to combo box
foreach (const QMessageAccountId &id, manager.queryAccounts()) {
QMessageAccount account(id);
...
}
if (accountDetails.isEmpty()) {
QMessageBox::warning(0, tr("Cannot send"), tr("No accounts are available to send with!"));
QCoreApplication::instance()->quit();
} else {
accountCombo->setCurrentIndex(0);
}
The code enter the (accountDetails.isEmpty()) on the device, but it is okay when at simulator. So the manager.queryAccounts() return an empty list.
What exactly is account? in simulator it is SMS and MMS. But why in the device is empty? The code doesn't initialize the manager so I can't trace how it is work. Oh, btw, manager is a QMessageManager instantiation. What should I do so it is work in the device?
I am using Nokia Qt SDK with QtMobility version 1.0.2, if that's helping.
Okay, I got the answer. The problem isn't with the application or the qt. But the certification. The QMessageManager somehow need to access the OS. It is described at the *.pro file, at the symbian:TARGET.CAPABILITY. That's called capabilities. And some capabilities can't be self-signed which is the default at the Project Setting. It is need to be signed.
I used Open Signed here: https://www.symbiansigned.com/app/page/public/openSignedOnline.do to get the file signed. After the file signed, install the signed file to the device, and the program can access the OS, and the QMessageManager's queryAccounts() won't return an empty result.
that's it. And the message can be sent.
I think it is kind of annoying when I need to test it to the device I need to signed it first. And the offline need a license which is not free, while I am just learning. *sigh
EDITED:
Somehow I am able to run it with self-signed. But I don't know exactly how it can be. What am I doing:
run the self-signed application with QtCreator. error: can't copy from computer to device
restart device
run the self-signed application with QtCreator. error: general OS related
Install application manually with PC Suite. Many warning.
And I forgot what's next
- try run with QtCreator. works fine.
- or uninstall with PC Suite first.

Resources