private static int run(string[] args, Ice.Communicator communicator, Ice.InitializationData initData) { // // Register the server manager. The server manager creates a new // 'server' (a server isn't a different process, it's just a new // communicator and object adapter). // Ice.Properties properties = communicator.getProperties(); properties.setProperty("Ice.ThreadPool.Server.Size", "2"); properties.setProperty("ServerManagerAdapter.Endpoints", "default -p 12010:udp"); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("ServerManagerAdapter"); // // We also register a sample server locator which implements the // locator interface, this locator is used by the clients and the // 'servers' created with the server manager interface. // ServerLocatorRegistry registry = new ServerLocatorRegistry(); Ice.Object @object = new ServerManagerI(registry, initData); adapter.add(@object, communicator.stringToIdentity("ServerManager")); registry.addObject(adapter.createProxy(communicator.stringToIdentity("ServerManager"))); Ice.LocatorRegistryPrx registryPrx = Ice.LocatorRegistryPrxHelper.uncheckedCast( adapter.add(registry, communicator.stringToIdentity("registry"))); ServerLocator locator = new ServerLocator(registry, registryPrx); adapter.add(locator, communicator.stringToIdentity("locator")); adapter.activate(); communicator.waitForShutdown(); return 0; }
public override int run(string[] args) { // // Register the server manager. The server manager creates a new // 'server' (a server isn't a different process, it's just a new // communicator and object adapter). // Ice.Properties properties = communicator().getProperties(); properties.setProperty("Ice.ThreadPool.Server.Size", "2"); properties.setProperty("ServerManagerAdapter.Endpoints", getTestEndpoint(0) + ":udp"); Ice.ObjectAdapter adapter = communicator().createObjectAdapter("ServerManagerAdapter"); // // We also register a sample server locator which implements the // locator interface, this locator is used by the clients and the // 'servers' created with the server manager interface. // ServerLocatorRegistry registry = new ServerLocatorRegistry(); Ice.Object @object = new ServerManagerI(registry, _initData, this); adapter.add(@object, Ice.Util.stringToIdentity("ServerManager")); registry.addObject(adapter.createProxy(Ice.Util.stringToIdentity("ServerManager"))); Ice.LocatorRegistryPrx registryPrx = Ice.LocatorRegistryPrxHelper.uncheckedCast( adapter.add(registry, Ice.Util.stringToIdentity("registry"))); ServerLocator locator = new ServerLocator(registry, registryPrx); adapter.add(locator, Ice.Util.stringToIdentity("locator")); adapter.activate(); communicator().waitForShutdown(); return(0); }
private void btnSaveConnection_Click(object sender, RoutedEventArgs e) { //Validate server address if (rbServerConnectAuto.IsChecked == true) { var endpoint = new ServerLocator().FindServer(); if (endpoint == null) { MessageBox.Show("Unable to find server. Please specify an address or start the server.", "Error locating server"); return; } tbxServerAddress.Text = endpoint.Address.ToString(); tbxPort.Text = endpoint.Port.ToString(); } PopUpMsg.DisplayMessage("Attempting to contact server..."); var address = tbxServerAddress.Text; var port = 8096; try { port = Convert.ToInt32(tbxPort.Text); } catch (Exception) { //let default through } this.Cursor = Cursors.AppStarting; btnSaveConnection.IsEnabled = false; Async.Queue("ConnectionCheck", () => Kernel.ConnectToServer(address, port, 20000), () => Dispatcher.Invoke(DispatcherPriority.Background, (System.Windows.Forms.MethodInvoker)ConnectionValidationDone)); }
public void ProcessRoutingUpdates(string headerValue) { if (string.IsNullOrEmpty(headerValue)) { throw new ArgumentNullException("headerValue"); } string[] array = headerValue.Split(new char[] { ',' }); foreach (string text in array) { try { IRoutingEntry routingEntry = RoutingEntryHeaderSerializer.Deserialize(text); if (ServerLocator.IsMailboxServerCacheKey(routingEntry.Key) && routingEntry.Destination.RoutingItemType == RoutingItemType.Server) { this.routeRefresherDiagnostics.IncrementTotalMailboxServerCacheUpdateAttempts(); if (this.mailboxServerCacheClient.AddEntry(routingEntry)) { string value = "MailboxServerCacheUpdate:" + text; this.routeRefresherDiagnostics.AddGenericInfo(value); this.routeRefresherDiagnostics.IncrementSuccessfulMailboxServerCacheUpdates(); } else { string value2 = "MailboxServerCacheFailure:" + text; this.routeRefresherDiagnostics.AddErrorInfo(value2); } } else if (ServerLocator.IsAnchorMailboxCacheKey(routingEntry.Key) && routingEntry.Destination.RoutingItemType == RoutingItemType.DatabaseGuid) { this.routeRefresherDiagnostics.IncrementTotalAnchorMailboxCacheUpdateAttempts(); if (this.anchorMailboxCacheClient.AddEntry(routingEntry)) { string value3 = "AnchorMailboxCacheUpdate:" + text; this.routeRefresherDiagnostics.AddGenericInfo(value3); this.routeRefresherDiagnostics.IncrementSuccessfulAnchorMailboxCacheUpdates(); } else { string value4 = "AnchorMailboxCacheFailure:" + text; this.routeRefresherDiagnostics.AddErrorInfo(value4); } } else { string value5 = "UnrecognizedRoutingEntry:" + text; this.routeRefresherDiagnostics.AddErrorInfo(value5); } } catch (ArgumentException) { string value6 = "DeserializationException:" + text; this.routeRefresherDiagnostics.AddErrorInfo(value6); } } }
/* Server Setup */ public Server(ILogger logger) { _simpleHost = new SimpleHost <MessageType>(true); _logger = logger; RegisterFunctions(); _simpleHost.NetManager.UnsyncedEvents = false; _simpleHost.NetManager.Start(IPAddress.Loopback, IPAddress.IPv6Loopback, 0); _queue = new MessageQueue(this); _serverLocator = ServerLocator.RegisterPortForServer(Port); #if DEBUG _simpleHost.NetManager.DisconnectTimeout = Int32.MaxValue; #endif }
static bool ConnectAutomatically(int timeout) { var endPoint = new ServerLocator().FindServer(); return(endPoint != null && ConnectToServer(endPoint.Address.ToString(), endPoint.Port, timeout)); }