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); }
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; }
public IEnumerator <ITask> RelayLoginHandler(RelayLogin login) { if (trace) { LogInfo("RelayLogin Received"); } // login and register with the relay try { UserSessionPrx userSessionPrx = relayCommunicator.loginAndRegister(login.Body.TerkLogin, login.Body.TerkPassword); // connect to the qwerk try { this.qwerkController = relayCommunicator.connectToQwerk(userSessionPrx, login.Body.QwerkLogin); } catch (PeerException e) { string failure = "Failed to connect to Qwerk " + login.Body.QwerkLogin + ": " + e; LogInfo(failure); login.ResponsePort.Post(generateFault(failure)); yield break; } } catch (Exception e) { string failure = "Failed to register with the relay: " + e; LogInfo(failure); login.ResponsePort.Post(generateFault(failure)); yield break; } login.ResponsePort.Post(DefaultUpdateResponseType.Instance); yield break; }
private Timer startSessionPinger(UserSessionPrx userSessionPrx) { // create and activate session pinger Trace.TraceInformation("Creating and activating session pinger"); return(new Timer(new TimerCallback(pingSession), // timer callback delegate userSessionPrx, // user session object 0, // how long to wait before starting the timer 5000)); // interval of time between pings (in milliseconds) }
private static void pingSession(object state) { try { UserSessionPrx userSessionPrx = (UserSessionPrx)state; userSessionPrx.ice_ping(); } catch (Exception e) { Trace.TraceError("Exception while pinging: " + e.ToString()); throw e; } }
public UserSessionPrx loginAndRegister(string userId, string password) { // log in Trace.TraceInformation("Logging in as user [" + userId + "]"); RouterPrx glacierRouter = RouterPrxHelper.checkedCast(communicator.getDefaultRouter()); UserSessionPrx userSessionPrx = UserSessionPrxHelper.uncheckedCast(glacierRouter.createSession(userId, password)); Trace.TraceInformation("Login successful! Session identity = [" + Util.identityToString(userSessionPrx.ice_getIdentity()) + "]"); // start session pinger sessionPinger = startSessionPinger(userSessionPrx); // create the servant and its proxy Trace.TraceInformation("Creating client servant and proxy"); ClientServant servant = new ClientServant(new DefaultClientServantEventHandler()); ObjectAdapter adapter = communicator.createObjectAdapter("Qwerk.Service.Client"); adapter.activate(); string category = glacierRouter.getServerProxy().ice_getIdentity().category; ObjectPrx servantProxy = adapter.add(servant, new Identity("clientCallbackReceiver", category)); TerkClientPrx terkClientServantPrx = TerkClientPrxHelper.uncheckedCast(servantProxy); // register =============================================================================================== Trace.TraceInformation("Login successful! Now registering with the relay..."); try { userSessionPrx.registerCallbacks(terkClientServantPrx, terkClientServantPrx); } catch (RegistrationException e) { Trace.TraceError("RegistrationException while trying to register callbacks with the relay."); throw e; } Trace.TraceInformation("Registration successful!"); return(userSessionPrx); }
private Timer startSessionPinger(UserSessionPrx userSessionPrx) { // create and activate session pinger Trace.TraceInformation("Creating and activating session pinger"); return new Timer(new TimerCallback(pingSession), // timer callback delegate userSessionPrx, // user session object 0, // how long to wait before starting the timer 5000); // interval of time between pings (in milliseconds) }