I am building a mobile application where my users can connect using accounts-facebook.
What I would like to do is refreshing their list of friends that use the app when they are logging in (is this a good way to keep this list up to date ?) or when they are connecting
I built something like this :
Meteor.startup(function(){
myFunctionToRefreshFriendLists()
});
Meteor.onConnection(function(conn) {
if (this.userId) {
myFunctionToRefreshFrindLists();
}
}
But this returns me "undefined", even when the user is connected. I know there is a problem using "this.userId" (this here does not seem relevant to me) but I do not know what to do ?
Any help appreciated, thank you !
Don't use Meteor.onConnection, as it will run every time a user starts a new connection. This can happen frequently depending on the stability of their connection; instead use Accounts.onLogin:
Accounts.onLogin(function(user){
console.log(user.user._id)
});
http://docs.meteor.com/#/full/accounts_onlogin
Related
I am trying to seek user feedback at the end of a google action session using actions sdk.
As per the Actions documentation (https://developers.google.com/actions/assistant/conversation-exits), I have set the cancel intent
"conversations" : {
...
"inDialogIntents": [
{
"name": "actions.intent.CANCEL"
},
...
and in my functions code I am calling a SimpleResponse as below:
app.intent('actions.intent.CANCEL', (conv, input) => {
conv.close(new SimpleResponse({
speech: 'Kindly rate between 1 and 5,
text: 'Rate between 1 and 5'
}));
});
When the user says goodbye, the above code gets called. The speech is heard and text displayed but the conversation immediately exits with an earcon.
The documentation mentions that the system will wait for 2 seconds before exiting but it seems to do so immediately. Is there a way to get this working? Thanks
It's not quite clear to me what you'd like to achieve. First of all, as long as you're using conv.close() method, you are ending the conversation. If you want to keep the mic open, you need to use conv.ask() method. But I'm not sure id you can use conv.ask() with actions.intent.CANCEL, because that event is there to get the user out, not to keep the conversation going. But I'm not %100 sure, you need to try it.
If what you're trying to achieve is something like this:
User: cancel
System: How would you rate our interaction?
User: Good.
earcon
Then, in my humble opinion, you probably shouldn't (and as I said you probably can't) do it. The docs clearly state that the purpose for custom exit behavior is:
to cleanup your fulfillment logic and respond to the user one last time.
Also, the docs doesn't say the system will wait for the user response for 2 second. It says the execution of the request (the time out for your fulfillment) is 2 seconds. Plus; if a user is canceling mid-conversation, chances are that the interaction was unsuccessful anyway. I'd rather create feedback dialog turns that are connected to the fallback intents and happy path(s).
Still, try to use conv.ask() instead and let me know if that works. (And please let me know by commenting.) Either case, though, I'd consider getting the feedback some other way.
I am doing firebase programming with iOS.
I could do normal searching with code like below
ref.child("Users").queryOrderedByChild("name").queryStartingAtValue(text).observeEventType(.Value, withBlock: { snapshot in
for u in snapshot.children{
print(user.name)
}
})
but i am confused, as i want to find people near me. every record has lat long values, where in the server i would put code to evaluate distance between my current location and friends location and filter them ? I dont want to loop through all items in above for block (Client side)
Also, can i write server code to make services hosted in firebase ? what is the recommended way to get data from big server like redshift ?
Is firebase really drag-drop development ? i did not find anything of that sort in firebase documentation ! firbase-ui is open source, but it gives obj c code and no drag and drop ! request answer please
I need to know when i start running my app if a new version exists in Google Play Store / ios app store.
I want to do it by comparing my running app version to the one in the store.
How do i read the app version from the store in run time ?
string url = "http://itunes.apple.com/lookup?bundleId=YourBundelID";
using (var webClient = new System.Net.WebClient())
{
string jsonString = webClient.DownloadString(string.Format(url));
var lookup = JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonString);
if (lookup != null
&& lookup.Count >= 1
&& lookup["resultCount"] != null
&& Convert.ToInt32(lookup["resultCount"].ToString()) > 0)
{
var results = JsonConvert.DeserializeObject<List<object>>(lookup[#"results"].ToString());
if (results != null && results.Count > 0)
{
var values = JsonConvert.DeserializeObject<Dictionary<string, object>>(results[0].ToString());
appStoreAppVersion = values.ContainsKey("version") ? values["version"].ToString() : string.Empty;
}
}
}
return appStoreAppVersion;
If there's no easy way to achieve this, build your own easy way ;-)
For example: with every upload to the app store you upload the current version info to an online resource you can access from your app. All you need is a webserver where you can either run your own API or just upload a file containing the version info.
Maybe not a solution you awaited, but it's definitely going to work.
There is no (easy) way to do that. The best way to do it would be to access the app details through some API but I don't think they make that (publicly) available. So the other way would probably to scrape the according sites, but I'm pretty sure they will be unhappy with that method and maybe their license even forbids it.
Also, mostly that kind of solutions is due to poor design. The user has to be able to use the old version for the length of days, although you should strive for fast adoption of your new version.
But just keep in mind while designing your backend etc. that you have to be backwards compatible.
Lastly, as a user I really hate those kind of messages. Depending on what kind of app it is I just want to use it then, not be forced to update, so go out, update, and try to do the thing I opened it for in the first place.
[I am new to ADO.NET and the Entity Framework, so forgive me if this questions seems odd.]
In my WPF application a user can switch between different databases at run time. When they do this I want to be able to do a quick check that the database is still available. What I have easily available is the ObjectContext. The test I am preforming is getting the count on the total records of a very small table and if it returns results then it passed, if I get an exception then it fails. I don't like this test, it seemed the easiest to do with the ObjectContext.
I have tried setting the connection timeout it in the connection string and on the ObjectConntext and either seem to change anything for the first scenario, while the second one is already fast so it isn't noticeable if it changes anything.
Scenario One
If the connect was down when before first access it takes about 30 seconds before it gives me the exception that the underlying provider failed.
Scenario Two
If the database was up when I started the application and I access it, and then the connect drops while using the test is quick and returns almost instantly.
I want the first scenario described to be as quick as the second one.
Please let me know how best to resolve this, and if there is a better way to test the connectivity to a DB quickly please advise.
There really is no easy or quick way to resolve this. The ConnectionTimeout value is getting ignored with the Entity Framework. The solution I used is creating a method that checks if a context is valid by passing in the location you which to validate and then it getting the count from a known very small table. If this throws an exception the context is not valid otherwise it is. Here is some sample code showing this.
public bool IsContextValid(SomeDbLocation location)
{
bool isValid = false;
try
{
context = GetContext(location);
context.SomeSmallTable.Count();
isValid = true;
}
catch
{
isValid = false;
}
return isValid;
}
You may need to use context.Database.Connection.Open()
I am trying to register to a "Device added/ Device removed" event using WMI. When I say device - I mean something in the lines of a Disk-On-Key or any other device that has files on it which I can access...
I am registering to the event, and the event is raised, but the EventType propery is different from the one I am expecting to see.
The documentation (MSDN) states : 1- config change, 2- Device added, 3-Device removed 4- Docking. For some reason I always get a value of 1.
Any ideas ?
Here's sample code :
public class WMIReceiveEvent
{
public WMIReceiveEvent()
{
try
{
WqlEventQuery query = new WqlEventQuery(
"SELECT * FROM Win32_DeviceChangeEvent");
ManagementEventWatcher watcher = new ManagementEventWatcher(query);
Console.WriteLine("Waiting for an event...");
watcher.EventArrived +=
new EventArrivedEventHandler(
HandleEvent);
// Start listening for events
watcher.Start();
// Do something while waiting for events
System.Threading.Thread.Sleep(10000);
// Stop listening for events
watcher.Stop();
return;
}
catch(ManagementException err)
{
MessageBox.Show("An error occurred while trying to receive an event: " + err.Message);
}
}
private void HandleEvent(object sender,
EventArrivedEventArgs e)
{
Console.WriteLine(e.NewEvent.GetPropertyValue["EventType"]);
}
public static void Main()
{
WMIReceiveEvent receiveEvent = new WMIReceiveEvent();
return;
}
}
Well, I couldn't find the code. Tried on my old RAC account, nothing. Nothing in my old backups. Go figure. But I tried to work out how I did it, and I think this is the correct sequence (I based a lot of it on this article):
Get all drive letters and cache
them.
Wait for the WM_DEVICECHANGE
message, and start a timer with a
timeout of 1 second (this is done to
avoid a lot of spurious
WM_DEVICECHANGE messages that start
as start as soon as you insert the
USB key/other device and only end
when the drive is "settled").
Compare the drive letters with the
old cache and detect the new ones.
Get device information for those.
I know there are other methods, but that proved to be the only one that would work consistently in different versions of windows, and we needed that as my client used the ActiveX control on a webpage that uploaded images from any kind of device you inserted (I think they produced some kind of printing kiosk).
Oh! Yup, I've been through that, but using the raw Windows API calls some time ago, while developing an ActiveX control that detected the insertion of any kind of media. I'll try to unearth the code from my backups and see if I can tell you how I solved it. I'll subscribe to the RSS just in case somebody gets there first.
Well,
u can try win32_logical disk class and bind it to the __Instancecreationevent.
You can easily get the required info
I tried this on my system and I eventually get the right code. It just takes a while. I get a dozen or so events, and one of them is the device connect code.