protected void Page_Load(object sender, EventArgs e) { try { AppReceiver receiver = new AppReceiver("v3", "RmxCs"); receiver.SignIn += new SignInArgument(receiver_SignIn); Label1.Text = receiver.Receive(); } catch (Exception ex) { Label1.Text = ex.Message; } }
private umdspersistentreceive(System.String[] args) : base("") { int Creates = 0; int Closes = 0; /* Process the command line arguments */ try { process_cmdline(args); if (sendAppName) { setProperty("appl-name", appl_name); } } catch (System.Exception e) { if (!help) { System.Console.Error.WriteLine("Error:" + e.Message); } System.Console.Error.WriteLine(UMDS.version()); System.Console.Error.WriteLine(purpose); System.Console.Error.WriteLine(usage); System.Environment.Exit(1); } /* If a user name was provided, get the password */ if (username != null) { get_password(); } /* * Create the server connection object for this application. The * application name is registered on the server when connected. The * server is not connected until start() is called. */ UMDSServerConnection svrconn = this; /* * If an application config file is provided, read it and set the server * connection properties. */ if (conffname != null) { if (read_config(svrconn, conffname) == false) { System.Environment.Exit(1); } } /* Set the list of servers, user name and password in the connection */ try { svrconn.setProperty("server-list", server_list); if (username != null) { svrconn.setProperty("user", username); svrconn.setProperty("password", password); } if (useTls) { svrconn.setProperty("use-tls", "1"); } if (trustStoreFile != null) { svrconn.setProperty("truststore", trustStoreFile); } if (trustStorePassword != null) { svrconn.setProperty("truststore-password", trustStorePassword); } } catch (UMDSException ex) { System.Console.Error.WriteLine("Error setting UMDS configuration: " + ex.ToString()); System.Environment.Exit(1); } /* * Now start the connection to a server. * If server-reconnect is enabled it will return asynchronously. * If server-reconnect is disabled, start() will return * when the connection is authenticated */ try { svrconn.start(); } catch (UMDSAuthenticationException) { System.Console.Error.WriteLine("Authentication failed - check user name/password requirements of the server"); System.Environment.Exit(1); } catch (UMDSException e) { System.Console.Error.WriteLine("Failed to create the server connection:" + e); System.Environment.Exit(1); } while (!svrconn.Authenticated && auth_failed == false) { System.Threading.Thread.Sleep(100); } if (auth_failed) { try { svrconn.close(); } catch (UMDSException ex) { System.Console.Error.WriteLine("Error closing connection: " + ex.ToString()); } return; } /* Create an array of receivers based on -N if it was used. */ AppReceiver[] rcv = new AppReceiver[numtopics]; Creates = numtopics; createCount = 0; try { for (int n = 0; n < numtopics; n++) { System.String fulltopic; /* Create a topic string. Append .N to the name if -N was used */ if (numtopics == 1) { fulltopic = topic; } else { fulltopic = topic + "." + n; } /* * Create the receiver object for this topic AppReceiver derives * from UMDSReceiver which on creation registers with the server. */ if (startSeqOffset > 0) { rcv[n] = new AppReceiver(svrconn, fulltopic, n, wildcard, new UMDSRecoverySequenceNumberCallbackimpl(startSeqOffset), (Object)startSeqOffset); } else { rcv[n] = new AppReceiver(svrconn, fulltopic, n, wildcard, null, null); } /* Copy the verbose flag from the command line */ rcv[n].verbose = verbose; } } catch (UMDSException e) { System.Console.Out.WriteLine("Failed to create receiver object:" + e); System.Environment.Exit(5); } /* Loop over all the receivers and start timing */ for (int n = 0; n < numtopics; n++) { rcv[n].newInterval(); } /* * Now start sending data until the number of requested messages have * been received or the server is no longer authenticated. (Most likely * disconnected) */ System.Console.Out.WriteLine("Printing Statistics every:" + stats_ms + " ms "); while (auth_failed == false) { /* Dump stats for each receiver object and reset the timing */ for (int n = 0; n < numtopics; n++) { if (stats_ms > 0) { rcv[n].print_bw(); } rcv[n].newInterval(); } /* Check the server connection hasn't encountered any * errors and exit if it has. This might come from * a receiver too. */ if (svrconn.Error != UMDS.ERRCODE.NO_ERROR) { System.Console.Error.WriteLine("Server Connection Error detected:" + svrconn.ErrorStr); break; } /* Wait for the statistics interval */ try { // Sleep the interval or 1 second. System.Threading.Thread.Sleep(((stats_ms > 0) ? stats_ms : 1000)); } catch (System.Threading.ThreadInterruptedException e) { } /* Count all the received messages on all the receivers */ int total_msg_count = 0; for (int n = 0; n < numtopics; n++) { total_msg_count = (int)(total_msg_count + rcv[n].total_msg_count); } /* If we received enough messages, end */ if (end_msgs > 0 && total_msg_count >= end_msgs) { break; } } /* Summarise the results and output */ print_summary(rcv); /* Close all the receivers and the connection, we are done */ Closes = 0; if (auth_failed == false) { try { for (int n = 0; n < numtopics; n++) { if (rcv[n] != null) { rcv[n].close(); Closes++; } } while (closeCount < Closes) { if (verbose) { System.Console.Error.WriteLine("Receivers: " + Closes + " Closed: " + closeCount); } System.Threading.Thread.Sleep(100); } if (verbose) { System.Console.Error.WriteLine("All receivers closed: Receivers: " + Closes + " Closed: " + closeCount); } System.Console.Error.WriteLine("Closing Connection "); svrconn.close(); } catch (UMDSException ex) { System.Console.Error.WriteLine("Error closing receiver: " + ex.ToString()); } } else { System.Console.Error.WriteLine("Exiting - no longer authenticated."); } System.Console.Error.WriteLine("Connection Closed"); System.Console.Error.WriteLine("Done"); }