registerResult = (Interop.PushClient.Result regResult, IntPtr msgPtr, IntPtr userData) =>
{
Log.Info(Interop.PushClient.LogTag, "Register Callback Called with " + regResult);
- string msg = "";
- if (msgPtr != IntPtr.Zero)
+
+ if (regResult < Interop.PushClient.Result.Success || regResult > Interop.PushClient.Result.SystemError)
+ {
+ Log.Error(Interop.PushClient.LogTag, "registerResult is called but has wrong resResult value");
+ task.SetException(PushExceptionFactory.CreateResponseException(Interop.PushClient.ServiceError.OpearationFailed));
+ }
+ else
{
- msg = Marshal.PtrToStringAnsi(msgPtr);
+ string msg = "";
+ if (msgPtr != IntPtr.Zero)
+ {
+ msg = Marshal.PtrToStringAnsi(msgPtr);
+ }
+ ServerResponse response = new ServerResponse();
+ response.ServerResult = (ServerResponse.Result)regResult;
+ response.ServerMessage = msg;
+ if (task.TrySetResult(response) == false)
+ {
+ Log.Error(Interop.PushClient.LogTag, "Unable to set the Result for register");
+ }
}
- ServerResponse response = new ServerResponse();
- response.ServerResult = (ServerResponse.Result)regResult;
- response.ServerMessage = msg;
- if (task.TrySetResult(response) == false)
+ lock (_lock)
{
- Log.Error(Interop.PushClient.LogTag, "Unable to set the Result for register");
+ Log.Error(Interop.PushClient.LogTag, "resigterResult is unset");
+ registerResult = null;
}
+ lock (_lock)
+ {
+ Log.Error(Interop.PushClient.LogTag, "resigterResult is unset");
+ registerResult = null;
+ }
};
Interop.PushClient.ServiceError result = Interop.PushClient.ServiceRegister(_connection, registerResult, IntPtr.Zero);
Log.Info(Interop.PushClient.LogTag, "Interop.PushClient.ServiceRegister Completed");