public UInt32 Connect(string userID, string password, string computerName)
        {
            UInt32 retVal = (UInt32)ReturnValues.bladeAccessBit;

            try
            {
                ITesterObjectCallback proxy        = OperationContext.Current.GetCallbackChannel <ITesterObjectCallback>();
                ProxyStruct           aProxyStruct = new ProxyStruct(computerName, userID, proxy);
                // TODO : 这里或许可以将这个list去掉,需要验证
                _CallbackProxyList.Add(aProxyStruct);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(retVal);
        }
Exemple #2
0
        public UInt32 Connect(string userID, string password, string computerName)
        {
            UInt32 retVal = (UInt32)ReturnValues.bladeAccessBit;

            try
            {
                WriteLine(string.Format("TesterObject::Connect Request from [userID:{0}] [ComputerName:{1}]", userID, computerName));
                ITesterObjectCallback proxy        = OperationContext.Current.GetCallbackChannel <ITesterObjectCallback>();
                ProxyStruct           aProxyStruct = new ProxyStruct(computerName, userID, proxy);
                _CallbackProxyList.Add(aProxyStruct);
            }
            catch (Exception e)
            {
                WriteLine("TesterObject::Connect Exception: " + makeUpExceptionString(e).ToString());
                throw e;
            }
            WriteLine(string.Format("TesterObject::Connect Granted to [userID:{0}] [ComputerName:{1}] [retVal:{2}]", userID, computerName, retVal));

            return(retVal);
        }
Exemple #3
0
 public ProxyStruct(string _computerName, string _UserName, ITesterObjectCallback _proxy)
 {
     m_computerName = _computerName;
     m_proxy        = _proxy;
     UserName       = _UserName;
 }
Exemple #4
0
 public ProxyStruct()
 {
     m_computerName = "";
     m_proxy        = null;
     UserName       = "";
 }
        /// <summary>
        /// This function pulls items out and sends to remote clients.
        /// Actually it calls the callback function in each client via proxy.
        /// </summary>
        private void doBladeEvents()
        {
            // TODO : Deal the event send from SendBladeEventCallback
            while (!_Exit)
            {
                //doBladeEventsGoing = true;
                List <BladeEventStruct> bladeEventArgList = new List <BladeEventStruct>();
                try
                {
                    // Use ReaderWriterLock
                    while (!_Exit)
                    {
                        try
                        {
                            _BladeEventQueueLock.AcquireWriterLock(20);
                            break;
                        }
                        catch (ApplicationException)
                        {
                            // Timeout
                            if (_Exit)
                            {
                                return;
                            }
                            continue;
                        }
                    }

                    if (_Exit)
                    {
                        continue;
                    }
                    if (_BladeEventQueue.Count == 0 || _TesterState.PauseEvents)
                    {
                        // Do not send event
                        Thread.Sleep(5);
                        continue;
                    }

                    while (_BladeEventQueue.Count > 0)
                    {
                        BladeEventStruct anEventStruct = _BladeEventQueue.Dequeue();
                        BladeEventArgs   anEventArg    = anEventStruct.EE;

                        bladeEventArgList.Add(anEventStruct);
                    }
                }
                finally
                {
                    if (_BladeEventQueueLock.IsWriterLockHeld)
                    {
                        // Release access right
                        _BladeEventQueueLock.ReleaseWriterLock();
                    }
                }
                if (_Exit)
                {
                    return;
                }
                foreach (BladeEventStruct anEventStruct in bladeEventArgList)
                {
                    BladeEventArgs anEventArg             = anEventStruct.EE;
                    List <ITesterObjectCallback> sentList = new List <ITesterObjectCallback>();

                    for (int i = 0; _CallbackProxyList != null && i < _CallbackProxyList.Count; i++)
                    {
                        ITesterObjectCallback callback = _CallbackProxyList.Get(i);
                        if (!sentList.Contains(callback))
                        {
                            sentList.Add(callback);
                            try
                            {
                                callback.BladeEventCallback(anEventArg);
                            }
                            catch (Exception e)
                            {
                                try
                                {
                                    StaticServerTalker.MessageString        = "Client callback proxy failed. ";
                                    StaticServerTalker.MessageStringContent = "Client callback proxy failed. " + Environment.NewLine + makeUpExceptionString(e).ToString();
                                }
                                catch { }
                                _CallbackProxyList.Remove(i);
                                sentList.Remove(callback);
                                i--;
                            }
                        }
                    }
                    if (_Exit)
                    {
                        break;
                    }
                }
            }
        }