Reputation: 8662
i have a else loop where two methods are executing,
static private void HandleClientStateCB(string clientName,
SPD.SPD_clientStateType state, object pb){
//IF()
else {
HandlePCAEvent(myDevice, SpoServer.PCA.Event.DeviceInactive, "");
HandlePCAEvent(myDevice, SpoServer.PCA.Event.DeviceDisconnect, "");
}
}
what my requirement was whenever client disconnected that time i need to make version to null.The existing condition is like this
static private void HandleClientEventCB(SPD.SPD_eventType type,
SPD.SPD_event this_event, object passback){
//------------------
string agentVersion = "0.0.0.0";
if (this_event.variableData.Length >= 6 ){
agentVersion = this_event.variableData[5].atr_value;
}
}
So what i did is i declared a boolean variable test private static bool test = false;
then i used in else loop
static private void HandleClientStateCB(string clientName,
SPD.SPD_clientStateType state, object pb){
//IF()
else {
HandlePCAEvent(myDevice, SpoServer.PCA.Event.DeviceInactive, "");
HandlePCAEvent(myDevice, SpoServer.PCA.Event.DeviceDisconnect, "");
test = true;
}
}
static private void HandleClientEventCB(SPD.SPD_eventType type,
SPD.SPD_event this_event, object passback){
//-------------------------------
string agentVersion = "0.0.0.0";
if (this_event.variableData.Length >= 6 && test==false ){
agentVersion = this_event.variableData[5].atr_value;
}
}
But this logic is not working,Can any body suggest any other logic so that disconnect time my version should be Null
Upvotes: 2
Views: 137
Reputation: 40497
How do you check that device is disconnected when you set test = true;
? If that condition is available in HandleClientEventCB
function just check it again. Else you need to pass true/false
to HandleClientEventCB
to know if device is disconnected.
As an aside don't you use different events for DeviceActive
, DeviceInactive
, DeviceConnect
and DeviceDisconnect
. If yes then you can know if HandleClientEventCB
is being called for disconnect or not.
Upvotes: 1