Example #1
0
 /// <summary>
 /// Un-Subscribes a user
 /// </summary>
 public bool Unsubscribe(string userName)
 {
     try
     {
         if (SearchHelper.UnAuthenticateUserCredentials(userName, _helper))
         {
             _callback         = OperationContext.Current.GetCallbackChannel <IUpDownSignalsClientContract>();
             _newSignalHandler = new NewSignalEventHandler(NewSignalHandler);
             NewSignalEvent   -= _newSignalHandler;
             Logger.Debug("Client Unsubscribed. UserName = "******"Unsubscribe");
             return(true);
         }
         else
         {
             Logger.Debug("Client Cant be unsubscirbed. UserName = "******"Subscribe");
             return(false);
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
         Logger.Error(exception, OType.FullName, "Unsubscribe");
         return(false);
     }
 }
Example #2
0
        /// <summary>
        /// Subscribes a user to the signals
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public string Subscribe(string userName)
        {
            Logger.Debug("New Client Connection received. UserName = "******"Subscribe");

            try
            {
                if (SearchHelper.AuthenticateUserCredentials(userName, _helper))
                {
                    Logger.Debug("Client Authenticated. UserName = "******"Subscribe");
                    _callback         = OperationContext.Current.GetCallbackChannel <IUpDownSignalsClientContract>();
                    _newSignalHandler = new NewSignalEventHandler(NewSignalHandler);

                    _communicationObject          = OperationContext.Current.InstanceContext;
                    _communicationObject.Closed  += CommunicationObjectOnClosed;
                    _communicationObject.Faulted += CommunicationObjectOnClosed;

                    NewSignalEvent -= _newSignalHandler;
                    NewSignalEvent += _newSignalHandler;
                    return("SUCCESS");
                }
                else
                {
                    Logger.Debug("Client Authentication failed. UserName = "******"Subscribe");
                    return("FAILED");
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                Logger.Error(exception, OType.FullName, "Subscribe");
                return("FAILED");
            }
        }