Ejemplo n.º 1
0
        public TerkServiceProvider(string peerUserId, TerkUserPrx peerObjectPrx, TerkCommunicator communicator)
        {
            this.peerUserId   = peerUserId;
            this.communicator = communicator;

            // get the collection of supported services from the peer's proxy
            //
            // Ugly hack to handle peers who don't support the getSupportedServices() method in the API.  This hack assumes
            // that the peer is a Qwerk, but that's ok for now since all non-qwerk TerkUsers already do support the new API.
            // TODO: remove this ugliness once we can assume that all TerkUsers support the new API.
            ProxyTypeIdToIdentityMap typeIdToProxyIdentityMap;

            try
            {
                typeIdToProxyIdentityMap = peerObjectPrx.getSupportedServices();
            }
            catch (Exception e)
            {
                Trace.TraceError("Exception while calling getSupportedServices()--maybe this TerkUser doesn't support the new API?", e);

                // assume we're dealing with a qwerk
                typeIdToProxyIdentityMap = QwerkPrxHelper.uncheckedCast(peerObjectPrx).getCommandControllerTypeToProxyIdentityMap();
            }

            if (typeIdToProxyIdentityMap != null)
            {
                foreach (DictionaryEntry entry in typeIdToProxyIdentityMap)
                {
                    string   key   = (string)entry.Key;
                    Identity value = (Identity)entry.Value;
                    supportedServices.Add(key, value);
                }
            }
        }
 public QwerkController connectToQwerk(UserSessionPrx userSessionPrx, string qwerkUserId)
 {
     // connect to the Qwerk
     Trace.TraceInformation("Connecting to Qwerk [" + qwerkUserId + "]...");
     try
     {
         this.userSessionPrx = userSessionPrx;
         ObjectPrx objectPrx = userSessionPrx.connectToPeer(qwerkUserId);
         if (objectPrx != null)
         {
             QwerkPrx qwerkPrx = QwerkPrxHelper.checkedCast(objectPrx);
             if (qwerkPrx != null)
             {
                 Trace.TraceInformation("Connection successful! (" + Util.identityToString(qwerkPrx.ice_getIdentity()) + ")");
                 return(new QwerkController(qwerkUserId, qwerkPrx, this));
             }
             else
             {
                 Trace.TraceError("   Connection failed!");
             }
         }
         else
         {
             Trace.TraceError("   connectToPeer() returned a null peer.  Bummer.");
         }
     }
     catch (PeerException e)
     {
         Trace.TraceError("   Connection failed due to a PeerException: {0}", e.reason);
         throw e;
     }
     return(null);
 }
Ejemplo n.º 3
0
        public IEnumerator <ITask> DirectLoginHandler(DirectLogin login)
        {
            if (trace)
            {
                LogInfo("DirectLogin Received");
            }

            try
            {
                TerkUserPrx terkUserPrx = directCommunicator.connectToPeer(login.Body.PeerIdentifier);
                if (trace)
                {
                    LogInfo("Connect complete!");
                }
                QwerkPrx qwerkPrx = QwerkPrxHelper.uncheckedCast(terkUserPrx);
                this.qwerkController = new QwerkController(login.Body.PeerIdentifier, qwerkPrx, directCommunicator);
            }
            catch (Exception e)
            {
                string failure = "Failed to connect to Qwerk '" + login.Body.PeerIdentifier + "': " + e;
                LogInfo(failure);
                login.ResponsePort.Post(generateFault(failure));
                yield break;
            }

            login.ResponsePort.Post(DefaultUpdateResponseType.Instance);
            yield break;
        }