Windows Phone 7 network traffic tracking - how? - windows-phone-7

I would need to track how much many bytes are sent and received by my application per session. Is there some API for this provided by the OS? Or is the only way to somehow manually track this every time I send/receive something with WebClient instance?

As keyboardP mentions. This is currently not supported by the API.

There's nothing built in but you could build a decorator IWebRequestCreate decorator implementation that tracks the bandwidth being used.

Related

Can I use a websocket connection within a serviceworker to receive notifications while my PWA is closed?

I was wondering whether it is possible to host a websocket connection within the boundaries of a serviceworker.js in order to receive notifications while my PWA is closed.
Given the documentation, the regular Push API is the proposed and go-to solution here, but I'm interested whether this is also possible via WebSockets, because my application would be way nicer to work with due to existing libraries for the programming language I use.
Also, websockets would give me an easy way of knowing whether or when my users are online / offline.
So, is this possible in a serviceworker.js, or would it lose the connection under certain circumstances?
Short answer, no.
The service worker is a somehow a thread of a web page. A web page (usually) lives in a tab of a browser (a PWA is also managed by a browser engine). Nowadays browsers are gearing towards performance and a lower memory footprint (think mobile). So the browser will kill (or sleep) your page as soon as it thinks it can because you're not using a page you're not viewing. Yes, a WebSocket will give you some priority against normal pages, but not that much.
Then there is the OS running the browser. Its main mission is to manage resources, like CPU cycles and RAM memory. And yes, it'll also try to kill you sooner than later.

Is there a way for my aplication to detect beacons in Powerapps?

I am trying to create an app using Powerapps where I need to interact with beacons ( their brand is Minew).
I want to start with something basic, like get a notification when the beacon is detected. Is it possible? If so, how?
As #davidgyoung mentioned, the simple answer is no. The most complex answer is it depends on whether the beacon can be exposed to the world (Internet) as a custom connector - there's currently no way to use bluetooth, for example, for communication between PowerApps and the external world.
If the beacon is Internet-connected, then it may be possible to use whatever the beacon is detecting (time, temperature, etc.) as a trigger in the custom connector. Once that is done, then you could create a flow that is started based on that trigger, and the flow can send a push notification to PowerApps (or the flow can store the notification in some data source, and PowerApps can poll for new notifications). You'll also need to manage subscriptions (which apps / users can listen to which notifications from the beacons).
So, this may technically be possible (depending on the capability of the Minew, which I don't know), but it will involve some work to get it done.
It's always hard to authoritatively say something is not possible (somebody can always build a way later and then prove you wrong!) but in years of professional beacon work, I have never heard of anybody using the Powerapps platform to build beacon apps. While I highly suspect that "no" is the simple answer to this question, I would welcome anyone knowing otherwise to provide another answer.

How to determine the size of a ParseObject.save() payload

I am doing some serious performance analysis against Parse.com on Android platform. I would like to know exactly the size of the request made to appname.parseapp.com for a certain ParseObject.save() operation.
Kind regards and happy Parsing!
Since the SDKs are all just wrappers over the REST API, that means all payloads are just HTTPS traffic.
You could use any number of tools to capture that traffic and see the size of the payload. I've used Fiddler before (it is free), just a matter of setting your PC as the proxy for your device.

What is the best way to handle incoming SMS messages?

I have a client who wants a solution to allow delivery people to text (SMS messaging) in that they have completed a pick up at a particular location. What I'm looking for is Code to read an imbound SMS message or a SMS component if appropiate. This would allow me to create a windows service to read the message and update a SQL record accordingly.
Probably not quite what you're looking for but one approach is to use a gateway like iTagg which provides a number of interfaces for developers to send and receive SMS/MMS etc. Depending on your location, iTagg may be no use but I'm sure there'll be an equivalent for your region.
Sometime ago I implemented something similar using a GSM modem. I think most of the GSM modems offer AT commands that can be used for receiving and sending SMS messages. At the time, I used a library in Java that provided a easy to use API. The commands to read and send SMS are really easy but I bet there is something in .Net for that purpose that can make the task even easier.
I made a little search and I found this article with an example of using AT commands to interact with a GSM phone. I looked into the supplied source and it includes a library with operations related to SMS.
In my previous project I used a Siemens GSM modem with a RS232 interface. It wasn't very expensive and was able to manage all the messages sent by onboard units placed in vehicles. But if you have a unused phone it can work as well.
Thanks Luke, I am thinking more of a GSM modem which would be connected to the server. I think this would give more control rather than go through a third party, but I take your point and will investigate further.

Is there some way to PUSH data from web server to browser?

Of course I am aware of Ajax, but the problem with Ajax is that the browser should poll the server frequently to find whether there is new data. This increases server load.
Is there any better method (even using Ajax) other than polling the server frequently?
Yes, what you're looking for is COMET http://en.wikipedia.org/wiki/Comet_(programming). Other good Google terms to search for are AJAX-push and reverse-ajax.
Yes, it's called Reverse Ajax or Comet. Comet is basically an umbrella term for different ways of opening long-lived HTTP requests in order to push data in real-time to a web browser. I'd recommend StreamHub Push Server, they have some cool demos and it's much easier to get started with than any of the other servers. Check out the Getting Started with Comet and StreamHub Tutorial for a quick intro. You can use the Community Edition which is available to download for free but is limited to 20 concurrent users. The commercial version is well worth it for the support alone plus you get SSL and Desktop .NET & Java client adapters. Help is available via the Google Group, there's a good bunch of tutorials on the net and there's a GWT Comet adapter too.
Nowadays you should use WebSockets.
This is 2011 standard that allows to initiate connections with HTTP and then upgrade them to two-directional client-server message-based communication.
You can easily initiate the connection from javascript:
var ws = new WebSocket("ws://your.domain.com/somePathIfYouNeed?args=any");
ws.onmessage = function (evt)
{
var message = evt.data;
//decode message (with JSON or something) and do the needed
};
The sever-side handling depend on your tenchnology stack.
Look into Comet (a spoof on the fact that Ajax is a cleaning agent and so is Comet) which is basically "reverse Ajax." Be aware that this requires a long-lived server connection for each user to receive notifications so be aware of the performance implications when writing your app.
http://en.wikipedia.org/wiki/Comet_(programming)
Comet is definitely what you want. Depending on your language/framework requirements, there are different server libraries available. For example, WebSync is an IIS-integrated comet server for ASP.NET/C#/IIS developers, and there are a bunch of other standalone servers as well if you need tighter integration with other languages.
I would strongly suggest to invest some time on Comet, but I dont know an actual implementation or library you could use.
For an sort of "callcenter control panel" of a web app that involved updating agent and call-queue status for a live Callcenter we developed an in-house solution that works, but is far away from a library you could use.
What we did was to implement a small service on the server that talks to the phone-system, waits for new events and maintains a photograph of the situation. This service provides a small webserver.
Our web-clients connects over HTTP to this webserver and ask for the last photo (coded in XML), displays it and then goes again, asking for the new photo. The webserver at this point can:
Return the new photo, if there is one
Block the client for some seconds (30 in our setup) waiting for some event to ocurr and change the photograph. If no event was generated at that point, it returns the same photo, only to allow the connection to stay alive and not timeout the client.
This way, when clients polls, it get a response in 0 to 30 seconds max. If a new event was already generated it gets it immediately), otherwise it blocks until new event is generated.
It's basically polling, but it somewhat smart polling to not overheat the webserver. If Comet is not your answer, I'm sure this could be implemented using the same idea but using more extensively AJAX or coding in JSON for better results. This was designed pre-AJAX era, so there are lots of room for improvement.
If someone can provide a actual lightweight implementation of this, great!
An interesting alternative to Comet is to use sockets in Flash.
Yet another, standard, way is SSE (Server-Sent Events, also known as EventSource, after the JavaScript object).
Comet was actually coined by Alex Russell from Dojo Toolkit ( http://www.dojotoolkit.org ). Here is a link to more infomration http://cometdproject.dojotoolkit.org/
There are other methods. Not sure if they are "better" in your situation. You could have a Java applet that connects to the server on page load and waits for stuff to be sent by the server. It would be a quite a bit slower on start-up, but would allow the browser to receive data from the server on an infrequent basis, without polling.
You can use a Flash/Flex application on the client with BlazeDS or LiveCycle on the server side. Data can be pushed to the client using an RTMP connection. Be aware that RTMP uses a non standard port. But you can easily fall back to polling if the port is blocked.
It's possible to achive what you're aiming at through the use of persistent http connections.
Check out the Comet article over at wikipedia, that's a good place to start.
You're not providing much info but if you're looking at building some kind of event-driven site (a'la digg spy) or something along the lines of that you'll probably be looking at implementing a hidden IFRAME that connects to a url where the connection never closes and then you'll push script-tags from the server to the client in order to perform the updates.
Might be worth checking out Meteor Server which is a web server designed for COMET. Nice demo and it also is used by twitterfall.
Once a connection is opened to the server it can be kept open and the server can Push content a long while ago I did with using multipart/x-mixed-replace but this didn't work in IE.
I think you can do clever stuff with polling that makes it work more like push by not sending content unchanged headers but leaving the connection open but I've never done this.
You could try out our Comet Component - though it's extremely experimental...!
please check this library https://github.com/SignalR/SignalR to know how to push data to clients dynamically as it becomes available
You can also look into Java Pushlets if you are using jsp pages.
Might want to look at ReverseHTTP also.

Resources