I am creating a Visual Studio Extension that performs some tasks when debugging of a specific application is stopped. This is my code for handling the debugger event:
...
DTE2 ide = Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider.GetService(typeof(DTE)) as DTE2;
if (ide != null)
{
debuggerEvents = ide.Events.DebuggerEvents;
debuggerEvents.OnEnterDesignMode += DebuggerEvents_OnEnterDesignMode;
}
}
private static void DebuggerEvents_OnEnterDesignMode(dbgEventReason Reason)
{
ThreadHelper.ThrowIfNotOnUIThread();
DTE2 ide = Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider.GetService(typeof(DTE)) as DTE2;
if (ide != null && ide.Debugger.CurrentProcess != null)
{
DebuggedProcName = ide.Debugger.CurrentProcess.Name;
}
if (Reason == dbgEventReason.dbgEventReasonStopDebugging &&
DebuggedProcName == "MyApp")
{
...
}
}
The problem is that ide.Debugger.CurrentProcess and .CurrentProgram is null in OnEnterDesignMode(). They are not null in OnEnterBreakMode() but that one might not be called. How can I determine the currently debugged program/process in a Visual Studio extension?
I wanted to perform a specific task if debugging of a certain project is stopped. Since using the event handler seems impossible I helped myself with a menu command that is executed when I press Ctrl + F5. After performing the task this command also kills the debugged process which effectively stops debugging. Rather rude, I guess, but I can live with this solution.
I'm trying to use the Tmp-String-0 variable within a dhcp site enabled.
My version is old and in production (2.1.12).
Here is the content of my dhcp file.
dhcp DHCP-Discover {
update control{
Tmp-String-0 = "%{sql: CALL sqlprocedure('%{DHCP-Agent-Circuit-Id}','%{DHCP-Gateway-IP-Address}','%{DHCP-Relay-Remote-Id}')}"
}
if(control:Tmp-String-0 != "" ) {
update reply {
DHCP-Message-Type = DHCP-Offer
}
}
else {
update reply {
DHCP-Message-Type = DHCP-NAK
}
}
update reply {
DHCP-Your-IP-Address = "control:Tmp-String-0"
}
}
And here is the result I have in debug mode.
rlm_sql_mysql: query: CALL sqlprocedure('value','1.2.3.4','value')
sql_xlat finished
rlm_sql (sql): Released sql socket id: 4
expand: %{sql: CALL sqlprocedure('%{DHCP-Agent-Circuit-Id}','%{DHCP-Gateway-IP-Address}','%{DHCP-Relay-Remote-Id}')} -> 10.10.10.10
++[control] returns noop
++? if (control:Tmp-String-0 != "" )
? Evaluating (control:Tmp-String-0 != "" ) -> TRUE
++? if (control:Tmp-String-0 != "" ) -> TRUE
++- entering if (control:Tmp-String-0 != "" ) {...}
+++[reply] returns noop
++- if (control:Tmp-String-0 != "" ) returns noop
++ ... skipping else for request 445: Preceding "if" was taken
ERROR: Failed parsing value "control:Tmp-String-0" for attribute DHCP-Your-
IP-Address: Failed to find IP address for control:Tmp-String-0
++[reply] returns fail
I don't know what is wrong with that maybe I should use the operator "=" instead of ":=".
What do you think?
Many thanks, Will
Did you try the following
update reply {
DHCP-Your-IP-Address = "Tmp-String-0"
}
Here is the requirement:
Start a socket server in the app which will receive messages from another app running in the same device.
Here is the stack:
Ionic1/cordova
Angular1
cordova plugin: https://www.npmjs.com/package/cordova-plugin-chrome-apps-sockets-tcpserver
Using the chrome's tcpServer plugin, I ended this code:
angular.module('starter', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
var tcpServer = window.chrome && window.chrome.sockets &&
window.chrome.sockets.tcpServer;
if(tcpServer) {
console.log('LOG tcpServer present')
tcpServer.create({}, function (createInfo) {
var serverSocketId = createInfo.socketId;
console.log('LOG', 'serverSocketId', serverSocketId)
if (serverSocketId > 0) {
tcpServer.listen(serverSocketId, '0.0.0.0', 8080, 50, function(resultCode) {
console.log('LOG', 'listening', resultCode)
});
} else {
console.log('LOG', 'Unable to create socket');
}
});
} else {
console.log('LOG', 'missing chrome.sockets.tcpServer')
}
});
})
And the result of this code is:
LOG tcpServer present
LOG serverSocketId 0
LOG Unable to create socket
Given that I've no experience in ionic1/iOS:
Is this my option to create this socket server?
0 means that the create method failed. What could I be doing wrong here?
Do I need some special permission in iOS to perform those actions? (Similar to Android)
I couldn't find resources/examples to help me doing this. Where should I search?
Any help is appreciated
ok this is something that start to show a few weeks ago, I have a parse server running on an ubuntu machine with version 2.3.3, I have a bunch of cloud functions running, nothing fancy just querying some specific Class, all the data in that class is public and all work most of the time just fine. However from time to time, calling a cloud function start to return invalid sessions error 209, even with a user logged or not, super weird, but what is even strange is that when that happens no one else can run the function, and every user start to got the same error.
The only way I can make it work again is restarting the server, also only happens with cloud functions and from the ios app, I saying this cause we have some other part calling functions from php but it seems those are not starting the problem
2017-02-21T01:26:57.676Z - Failed running cloud function partnersv2 for user undefined with:
Input: {"k":"","searchType":"","category":"comida"}
Error: {"code":141,"message":{"code":209,"message":"invalid session token"}}
2017-02-21T01:26:57.669Z - invalid session token
2017-02-21T01:26:55.738Z - ParseError { code: 209, message: 'invalid session token' }
2017-02-21T01:26:55.737Z - Error generating response. ParseError {
code: 141,
message: ParseError { code: 209, message: 'invalid session token' } }
I have no idea why is this happening, also I don't think is related to the legacy session cause this server and the user are new, we start developing this a few months ago is not a ported app from the old service
One thing we are doing a lot is removing from the dashboard sessions at will, cause we are testing and developing, not sure if this could be a reason, but what about when the user is undefined, it shouldn't even try to use session I think, or maybe a user that was actually logged could be the culprit, setting the server to VERBOSE is not telling anything else as well, just the params and the call which it doesn't look weird to me, am looking for someone that maybe can put me in the right direction of maybe how the session work or something, thank you for any help
EDIT 1:
This is the cloud function that is trowing the error
Parse.Cloud.define('partnersv2', function (req, res) {
var searchType = req.params.searchType,
k = req.params.k,
category = req.params.category,
query;
query = new Parse.Query('Partner');
query.addDescending('is_open');
query.equalTo('enabled', true);
query.equalTo('category', category);
query.select(['name', 'phone', 'delivery_eta', 'keys', 'price_range', 'is_new', 'cover', 'recommended', 'open_time', 'min_order', 'delivery_rank', 'logo', 'comingsoon', 'category', 'is_open']);
if (searchType !== '' && searchType !== undefined && k !== '' && k !== undefined) {
if (searchType === 'Tag') {
query.equalTo('tags', k);
} else {
query.equalTo('name', k);
}
}
query.limit(1000);
query.find({
success: function (results) {
if (results.length > 0) {
res.success(results);
} else {
res.error('404 not found');
}
},
error: function (error) {
res.error(error);
}
});
});
and this is a screenshot of the ACL col
Use Master Key
Parse.Cloud.define('partnersv2', function (req, res) {
//var token = req.user.getSessionToken() // getSession Token return r: (yourkey);
var searchType = req.params.searchType,
k = req.params.k,
category = req.params.category,
query;
query = new Parse.Query('Partner');
query.addDescending('is_open');
query.equalTo('enabled', true);
query.equalTo('category', category);
query.select(['name', 'phone', 'delivery_eta', 'keys', 'price_range', 'is_new', 'cover', 'recommended', 'open_time', 'min_order', 'delivery_rank', 'logo', 'comingsoon', 'category', 'is_open']);
if (searchType !== '' && searchType !== undefined && k !== '' && k !== undefined) {
if (searchType === 'Tag') {
query.equalTo('tags', k);
} else {
query.equalTo('name', k);
}
}
query.limit(1000);
query.find({
useMasterKey: true, // sessionToken: token
success: function (results) {
if (results.length > 0) {
res.success(results);
} else {
res.error('404 not found');
}
},
error: function (error) {
res.error(error);
}
});
});
I'm trying to tap on the incoming call using a following background service in NativeScript and searching the incoming number in Firebase Database.
The firebase.query from nativescript-plugin-firebase code works fine if the application UI is visible or minimized in Android but when the application is closed (however, the service is running in background), it throws firebase.query: TypeError: Cannot read property 'child' of null error. Any Idea.
app/broadcastreceivers/NotificationEventReceiver.js:
var application = require("application");
var firebase = require("nativescript-plugin-firebase");
var incomingCallDetected = false;
var TelephonyManager = application.android.context.getSystemService(android.content.Context.TELEPHONY_SERVICE);
android.support.v4.content.WakefulBroadcastReceiver.extend("com.tns.broadcastreceivers.NotificationEventReceiver", {
onReceive: function (context, intent) {
if (intent.getAction() === 'android.intent.action.PHONE_STATE') {
incomingCallDetected = true;
}
}
});
var callStateListener = android.telephony.PhoneStateListener.extend({
onCallStateChanged: function (state, phoneNumber) {
if (incomingCallDetected && state === 1) { // incoming call ringing
firebase.query(
function(result) {
console.log(JSON.stringify(result));
},
"/calls",
{
singleEvent: true,
orderBy: {
type: firebase.QueryOrderByType.CHILD,
value: 'PhoneNumber'
},
range: {
type: firebase.QueryRangeType.EQUAL_TO,
value: phoneNumber.replace(/\s+/g, '').substr(-10)
}
}
);
incomingCallDetected = false;
}
}
});
TelephonyManager.listen(new callStateListener(), android.telephony.PhoneStateListener.LISTEN_CALL_STATE);
Update: This line in nativescript-plugin-firebase causes the problem because firebaseInstance does not persist in the service once the application is closed.
I think thats because the firebase is never initiated in background service, I guess you are doing it only in app code so it works when it is on foreground.