Windows Xbox JavaScript UWP APP get CPU/Memory Usage - javascript

Developing a JavaScript UWP app on Xbox and I would like to know how can I get CPU and memory usage information
I found this API, Windows.System.Diagnostics.ProcessCpuUsage
but the getReport method is not defined as claimed by Microsoft documentation
https://learn.microsoft.com/en-us/uwp/api/windows.system.diagnostics.processcpuusage
Any help would be greatly appreciated

With the Windows 10 Fall Creators Update 1709 (build 16299 and later) we have added a number of new diagnostics APIs to the UWP API surface to support scenarios like this. Please be sure to install and target the SDK version 16299 (or later). Here is a related blog post:
https://blogs.windows.com/buildingapps/2017/06/28/uwp-app-diagnostics/

I thought I'd add a quick code snippet here to reflect the JavaScript part of the question:
Keep in mind this is only here as a jump-start for anyone trying to get a memory report for your app as it's running from within JS. This is only example code and not terribly fault-tolerant.
Windows.System.AppDiagnosticInfo.requestInfoAsync().then((allProc) => {
let proc = allProc[0];
let allGroups = proc.getResourceGroups();
let procGroup = allGroups[0];
let memReport = procGroup.getMemoryReport();
console.log(memReport);
console.log(
` [${memReport.commitUsageLevel}] : commitUsageLevel \n` +
` [${memReport.commitUsageLimit}] : commitUsageLimit \n` +
` [${memReport.privateCommitUsage}] : privateCommitUsage \n` +
` [${memReport.totalCommitUsage}] : totalCommitUsage \n`
)
});

Related

Enable users of a WebRtc app to download webrtc logs via javascript

I've seen the following:
chrome://webrtc-internals
However I'm looking for a way to let users click a button from within the web app to either download or - preferably - POST WebRtc logs to an endpoint baked into the app. The idea is that I can enable non-technical users to share technical logs with me through the click of a UI button.
How can this be achieved?
Note: This should not be dependent on Chrome; Chromium will also be used as the app will be wrapped up in Electron.
You need to write a javascript equivalent that captures all RTCPeerConnection API calls. rtcstats.js does that but sends all data to a server. If you replace that behaviour with storing it in memory you should be good.
This is what I ended up using (replace knockout with underscore or whatever):
connectionReport.signalingState = connection.signalingState;
connectionReport.stats = [];
connection.getStats(function (stats) {
const reportCollection = stats.result();
ko.utils.arrayForEach(reportCollection, function (innerReport) {
const statReport = {};
statReport.id = innerReport.id;
statReport.type = innerReport.type;
const keys = innerReport.names();
ko.utils.arrayForEach(keys, function (reportKey) {
statReport[reportKey] = innerReport.stat(reportKey);
})
connectionReport.stats.push(statReport);
});
connectionStats.push(connectionReport);
});
UPDATE:
It appears that this getStats mechanism is soon-to-be-deprecated.
Reading through js source of chrome://webrtc-internals, I noticed that the web page is using a method called chrome.send() to send messages like chrome.send('enableEventLogRecordings');, to execute logging commands.
According to here:
chrome.send() is a private function only available to internal chrome
pages.
so the function is sandboxed which makes accessing to it not possible

JS OAuth 2.0 on Windows Phone 8.1

So, I'm trying to create a Gitter client for Windows Phone and to do so I need to use Bearer OAuth on their API. This process seems to result in a redirection to a gitter webpage (to get access tokens) and then it redirects to a web page specififed by my application. However obviously an APP is not a web page, so how am I supposed to get the returned temporary access token to use the API?
I've read a little bit about using ms-app://<security identifier> but it's all very fuzzy and little to no information seems to be about using it without using c#, but that's not what I'm looking for.
Any help would be greatly appreciated!
EDIT I just noticed this has been asked here oAuth 2.0 in Windows Phone 8.1 but hasn't been awnsered. Sorry for the duplication.
Seems that it was under my nose the whole entire time!
You can use Windows.Security.Authentication.Web.WebAuthenticationBroker.authenticateAndContinue(startURI, endURI);
(docs are mainly c# but here: http://msdn.microsoft.com/en-us/library/dn631755.aspx)
i.e
var redirect_uri = 'ms-app://<sid>';
var client_id = '<client id>';
// testing
var requestUri = new Windows.Foundation.Uri(
'https://<site>/?client_id=' + client_id + '&redirect_uri=' + redirect_uri
);
Windows.Security.Authentication.Web.WebAuthenticationBroker.authenticateAndContinue(requestUri, Windows.Foundation.Uri(redirect_uri));
app.addEventListener("activated", function (args) {
if (args.detail.kind == activation.ActivationKind.webAuthenticationBrokerContinuation) {
//take oauth response and continue login process
console.log(args.detail.webAuthenticationResult);
}
//Handle normal activiation...(hidden)
});
source: http://blog.stevenedouard.com/andcontinue-methods-for-windows-universal-apps/

How to stream audio from browser to WebRTC native C++ application

I have so far managed to run the following sample:
WebRTC native c++ to browser video streaming example
The sample shows how to stream video from a native C++ application (peerconnection_client.exe) to the browser (I am using Chrome). This works fine and I can see myself in the browser.
What I would like to do is to stream audio from the browser to the native application but I am not sure how. Can anyone give me some pointers please?
I'm trying to find a way to stream both video and audio from browser to my native program. and here is my way so far.
To stream video from browser to your native program without gui, just follow the example here. https://chromium.googlesource.com/external/webrtc/+/refs/heads/master/examples/peerconnection/client/
use AddOrUpdateSink to add your own VideoSinkInterface and you will receive your frame data in callback void OnFrame(const cricket::VideoFrame& frame). Instead of render the frame to GUI as the example does, you can do whatever you want.
To stream audio from browser to your native program without real audio device. you can use a fake audio device.
modify variable rtc_use_dummy_audio_file_devices to true in file https://chromium.googlesource.com/external/webrtc/+/master/webrtc/build/webrtc.gni
invoke the global static function to specify the filename webrtc::FileAudioDeviceFactory::SetFilenamesToUse("", "file_to_save_audio");
patch file_audio_device.cc with the code blew. (as I write this answer, FileAudioDevice has some issues, may already be fixed)
recompile your program, touch file_to_save_audio and you will see pcm data in file_to_save_audio after webrtc connection is established.
patch:
diff --git a/webrtc/modules/audio_device/dummy/file_audio_device.cc b/webrtc/modules/audio_device/dummy/file_audio_device.cc
index 8b3fa5e..2717cda 100644
--- a/webrtc/modules/audio_device/dummy/file_audio_device.cc
+++ b/webrtc/modules/audio_device/dummy/file_audio_device.cc
## -35,6 +35,7 ## FileAudioDevice::FileAudioDevice(const int32_t id,
_recordingBufferSizeIn10MS(0),
_recordingFramesIn10MS(0),
_playoutFramesIn10MS(0),
+ _initialized(false),
_playing(false),
_recording(false),
_lastCallPlayoutMillis(0),
## -135,12 +136,13 ## int32_t FileAudioDevice::InitPlayout() {
// Update webrtc audio buffer with the selected parameters
_ptrAudioBuffer->SetPlayoutSampleRate(kPlayoutFixedSampleRate);
_ptrAudioBuffer->SetPlayoutChannels(kPlayoutNumChannels);
+ _initialized = true;
}
return 0;
}
bool FileAudioDevice::PlayoutIsInitialized() const {
- return true;
+ return _initialized;
}
int32_t FileAudioDevice::RecordingIsAvailable(bool& available) {
## -236,7 +238,7 ## int32_t FileAudioDevice::StopPlayout() {
}
bool FileAudioDevice::Playing() const {
- return true;
+ return _playing;
}
int32_t FileAudioDevice::StartRecording() {
diff --git a/webrtc/modules/audio_device/dummy/file_audio_device.h b/webrtc/modules/audio_device/dummy/file_audio_device.h
index a69b47e..3f3c841 100644
--- a/webrtc/modules/audio_device/dummy/file_audio_device.h
+++ b/webrtc/modules/audio_device/dummy/file_audio_device.h
## -185,6 +185,7 ## class FileAudioDevice : public AudioDeviceGeneric {
std::unique_ptr<rtc::PlatformThread> _ptrThreadRec;
std::unique_ptr<rtc::PlatformThread> _ptrThreadPlay;
+ bool _initialized;;
bool _playing;
bool _recording;
uint64_t _lastCallPlayoutMillis;
I know this is an old question, but I struggled myself to find a solution currently so I thought sharing is appreciated.
There's is one more or less simple way to get an example running which streams from the browser to native code.You need the webrtc source http://www.webrtc.org/native-code/development
The two tools you need are the peerconnection server and client. Both can be found in the folder talk/example/peerconnection
To get it working you need to patch it to enable DTLS for the peerconnection client. So patch it with the patch provided here https://code.google.com/p/webrtc/issues/detail?id=3872 and rebuild the client. Now you are set up on the native site!
For the browser I recommend the peer2peer example from here https://github.com/GoogleChrome/webrtc after starting the peerconnection_server and connection the peerconnection_client try to connect with the peer2peer example.
Maybe a connection constraint is necessary:
{
"DtlsSrtpKeyAgreement": true
}
you could use the following example which implement a desktop client for appRTC.
https://github.com/TemasysCommunications/appRTCDesk
this completes and interop with the web client, android client and iOs client provided by the open source implementation at webrtc.org, giving you a full suite of clients to work with their free server. peer connection_{client|server} is an old example from the lib jingle time (pre webrtc) and does not interop with anything else.

ActiveXObject("Outlook.Application") Not working when Outlook is open

I have a javascript that works when Outlook is closed. However, if outlook is open I receive "Automation Server" error.
var outlookApp = new ActiveXObject('Outlook.Application');
var nameSpace = outlookApp.getNameSpace("MAPI");
mailFolder = nameSpace.getDefaultFolder(6);
email = mailFolder.Items.add('IPM.Note.FormA');
email.Subject="Quote: "+ quoteNum + ' | Part#: '+ partNum;
email.To = "lcarreiro#epectec.com"; //who will to be going to
email.HTMLBody = "Quote Attached " + quoteNum;
email.display(0);
Any suggestions besides changing IE setting as I have already done so....
Probably a little late to help you but hopefully it helps anyone else who ends up here.
I was having the same issue and stumbled across https://stackoverflow.com/a/3779945/1002621 which answered a similar question.
Basically the issue is because when you run Visual Studio as an Administrator and Outlook with normal privileges you are no longer allowed to get an instance to the existing Outlook application but as it is single instance it won't create a new one.
This is only an issue if you initiate debugging directly from Visual Studio just starting your own instance of IE makes the problem go away.

how to communicate two webworkers html5?

I am going through webworkers documentation, I cant find any api that support communication between two webworkers. Here is my context, now i need to communicate worker1 with worker2 directly? not from UI. its just like thread messaging.
app.js
var worker1 = new Worker("worker1.js");
var worker2 = new Worker("worker2.js");
worker1.onmessage=function(e) {
console.log("msg from worker1"+e.data);
}
worker1.postMessage("ping worker1");
worker2.onmessage=function(e) {
console.log("msg from worker2"+e.data);
}
worker2.postMessage("ping worker2");
worker1.js
onmessage=function(e) {
postMessage(e.data)
}
worker2.js
onmessage=function(e) {
postMessage(e.data)
}
Is it possible ?
does any HTML5 API support it?
if support how can I implement direct communication?
If it is possible please paste some example to do it.
I got solution after working some time on MessageChannel. Here is demo of working link

Categories

Resources