Ejemplo n.º 1
0
        private PresenceApiIntegerResult performUnsubscription(string sessionId, unsubscribe unsubscribeRequest)
        {
            PresenceApiIntegerResult result = new PresenceApiIntegerResult();

            try
            {
                ResponseStatusType resType = server.unsubscribe(sessionId, unsubscribeRequest);
                if (resType.status == ResponseStatusTypeStatus.SUCCESS)
                {
                    result.ResultCode = GenericPresenceApiResultCode.Success;
                }
                else
                {
                    result.ResultCode = GenericPresenceApiResultCode.ApiFault;
                }
            }
            catch (FaultException f)
            {
                log("API error during unsubscribe: " + f.Message, 2);
                result.ResultCode = GenericPresenceApiResultCode.ApiFault;
            }
            catch (CommunicationException c)
            {
                log("Communication error: " + c.Message, 2);
                result.ResultCode = GenericPresenceApiResultCode.CommunicationError;
            }
            return(result);
        }
Ejemplo n.º 2
0
        public void EndTest2()
        {
            if (!string.IsNullOrEmpty(adminSessionId))
            {
                if (!string.IsNullOrEmpty(userSessionId))
                {
                    if (subscriptionId != 0)
                    {
                        PresenceApiIntegerResult unsubscribeResult = UnsubscribeAll(userSessionId, subscriptionId);
                        log("Result of event unsubscription: " + unsubscribeResult.ResultCode, 4);
                    }
                    PresenceApiIntegerResult logoutResult = Logout(userSessionId);
                    log("Result of user logout: " + logoutResult.ResultCode, 4);
                }

                if (endPointId != 0)
                {
                    PresenceApiIntegerResult unregisterResult = UnregisterEndPoint(adminSessionId, endPointId);
                    log("Result of endpoint unregister: " + unregisterResult.ResultCode, 4);
                }

                PresenceApiIntegerResult logoutResult2 = Logout(adminSessionId);
                log("Result of admin logout: " + logoutResult2.ResultCode, 4);
            }
        }
Ejemplo n.º 3
0
        public PresenceApiIntegerResult UnregisterEndPoint(string sessionId, int endpointId)
        {
            PresenceApiIntegerResult result = new PresenceApiIntegerResult();

            try
            {
                ResponseStatusType resType = server.unregisterEndPoint(sessionId, new unregisterEndPoint {
                    endPointID = endpointId
                });
                if (resType.status == ResponseStatusTypeStatus.SUCCESS)
                {
                    result.ResultCode = GenericPresenceApiResultCode.Success;
                }
                else
                {
                    result.ResultCode = GenericPresenceApiResultCode.ApiFault;
                }
            }
            catch (FaultException f)
            {
                log("API error during unregisterEndPoint: " + f.Message, 2);
                result.ResultCode = GenericPresenceApiResultCode.ApiFault;
            }
            catch (CommunicationException c)
            {
                log("Communication error: " + c.Message, 2);
                result.ResultCode = GenericPresenceApiResultCode.CommunicationError;
            }
            return(result);
        }
Ejemplo n.º 4
0
        public PresenceApiIntegerResult Logout(string sessionId)
        {
            PresenceApiIntegerResult result = new PresenceApiIntegerResult();

            try
            {
                ResponseStatusType resType = server.logout(sessionId, new logout {
                });
                if (resType.status == ResponseStatusTypeStatus.SUCCESS)
                {
                    result.ResultCode = GenericPresenceApiResultCode.Success;
                }
                else
                {
                    result.ResultCode = GenericPresenceApiResultCode.ApiFault;
                }
            }
            catch (FaultException f)
            {
                log("Error received during logout processing: " + f.Message, 2);
                result.ResultCode = GenericPresenceApiResultCode.ApiFault;
            }
            catch (CommunicationException c)
            {
                log("Communication error: " + c.Message, 2);
                result.ResultCode = GenericPresenceApiResultCode.CommunicationError;
            }
            return(result);
        }
Ejemplo n.º 5
0
        public bool StartTest2()
        {
            LoginResult adminLoginRes, userLoginRes;

            adminLoginRes = EstablishAdminSession();
            if (adminLoginRes.ResultCode == LoginResultCode.Success)
            {
                adminSessionId = adminLoginRes.SessionId;
                log("Successfully logged in admin", 4);
                PresenceApiIntegerResult registerResult = RegisterEndPoint(adminLoginRes.SessionId, 3600);
                if (registerResult.ResultCode == GenericPresenceApiResultCode.Success)
                {
                    endPointId = registerResult.IntegerId;
                    log("Successfully registered endpoint " + callbckServerAddress + ", endpoint id " + endPointId, 4);
                    userLoginRes = EstablishUserSession(adminLoginRes.SessionId, "sste-dect");
                    if (userLoginRes.ResultCode == LoginResultCode.Success)
                    {
                        log("Successfully logged in user sste-dect", 4);
                        userSessionId = userLoginRes.SessionId;
                        PresenceApiIntegerResult subscribeResult = Subscribe(userSessionId, endPointId, 3600, new List <string> {
                            "*****@*****.**", "*****@*****.**"
                        });
                        if (subscribeResult.ResultCode == GenericPresenceApiResultCode.Success)
                        {
                            subscriptionId = subscribeResult.IntegerId;
                            log("Successfully started event subscription, id " + subscriptionId, 4);
                            return(true);
                        }
                        else
                        {
                            log("Unable to start event subscription: " + subscribeResult.ResultCode, 2);
                        }
                    }
                    else
                    {
                        log("Unable to log in user [email protected]", 2);
                    }
                }
                else
                {
                    log("Unable to register endpoint " + callbckServerAddress + ": " + registerResult.ResultCode, 2);
                }
            }
            else
            {
                log("Unable to log in admin user: " + adminLoginRes.ResultCode, 2);
            }
            EndTest2();
            return(false);
        }
Ejemplo n.º 6
0
        private PresenceApiIntegerResult performSubscription(string sessionId, subscribe subscribeRequest)
        {
            PresenceApiIntegerResult result = new PresenceApiIntegerResult();

            try
            {
                subscribeResponse subRes = server.subscribe(sessionId, subscribeRequest);
                result.IntegerId  = subRes.subscriptionID;
                result.ResultCode = GenericPresenceApiResultCode.Success;
            }
            catch (FaultException f)
            {
                log("API error during subscribe: " + f.Message, 2);
                result.ResultCode = GenericPresenceApiResultCode.ApiFault;
            }
            catch (CommunicationException c)
            {
                log("Communication error: " + c.Message, 2);
                result.ResultCode = GenericPresenceApiResultCode.CommunicationError;
            }
            return(result);
        }
Ejemplo n.º 7
0
        private PresenceApiIntegerResult performEndPointRegistration(string sessionId, registerEndPoint registrationMessage)
        {
            PresenceApiIntegerResult result = new PresenceApiIntegerResult();

            try
            {
                registerEndPointResponse endpointRes = server.registerEndPoint(sessionId, registrationMessage);
                result.IntegerId  = endpointRes.endPointID;
                result.ResultCode = GenericPresenceApiResultCode.Success;
            }
            catch (FaultException f)
            {
                log("API error during registerEndPoint: " + f.Message, 2);
                result.ResultCode = GenericPresenceApiResultCode.ApiFault;
            }
            catch (CommunicationException c)
            {
                log("Communication error: " + c.Message, 2);
                result.ResultCode = GenericPresenceApiResultCode.CommunicationError;
            }
            return(result);
        }