public Request(LocatorI locator, string operation, Ice.OperationMode mode, byte[] inParams, Dictionary<string, string> context, Ice.AMD_Object_ice_invoke amdCB) { _locator = locator; _operation = operation; _mode = mode; _inParams = inParams; _context = context; _amdCB = amdCB; }
initialize() { Ice.Properties properties = _communicator.getProperties(); bool ipv4 = properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; bool preferIPv6 = properties.getPropertyAsInt("Ice.PreferIPv6Address") > 0; string address; if(ipv4 && !preferIPv6) { address = properties.getPropertyWithDefault("IceGridDiscovery.Address", "239.255.0.1"); } else { address = properties.getPropertyWithDefault("IceGridDiscovery.Address", "ff15::1"); } int port = properties.getPropertyAsIntWithDefault("IceGridDiscovery.Port", 4061); string intf = properties.getProperty("IceGridDiscovery.Interface"); if(properties.getProperty("IceGridDiscovery.Reply.Endpoints").Length == 0) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("udp"); if(intf.Length > 0) { s.Append(" -h \""); s.Append(intf); s.Append("\""); } properties.setProperty("IceGridDiscovery.Reply.Endpoints", s.ToString()); } if(properties.getProperty("IceGridDiscovery.Locator.Endpoints").Length == 0) { properties.setProperty("IceGridDiscovery.Locator.AdapterId", Guid.NewGuid().ToString()); } _replyAdapter = _communicator.createObjectAdapter("IceGridDiscovery.Reply"); _locatorAdapter = _communicator.createObjectAdapter("IceGridDiscovery.Locator"); // We don't want those adapters to be registered with the locator so clear their locator. _replyAdapter.setLocator(null); _locatorAdapter.setLocator(null); string lookupEndpoints = properties.getProperty("IceGridDiscovery.Lookup"); if(lookupEndpoints.Length == 0) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("udp -h \""); s.Append(address); s.Append("\" -p "); s.Append(port); if(intf.Length > 0) { s.Append(" --interface \""); s.Append(intf); s.Append("\""); } lookupEndpoints = s.ToString(); } Ice.ObjectPrx lookupPrx = _communicator.stringToProxy("IceGrid/Lookup -d:" + lookupEndpoints); lookupPrx = lookupPrx.ice_collocationOptimized(false); // No colloc optimization for the multicast proxy! try { lookupPrx.ice_getConnection(); // Ensure we can establish a connection to the multicast proxy } catch (Ice.LocalException ex) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("unable to establish multicast connection, IceGrid discovery will be disabled:\n"); s.Append("proxy = "); s.Append(lookupPrx.ToString()); s.Append("\n"); s.Append(ex); throw new Ice.PluginInitializationException(s.ToString()); } LocatorPrx voidLo = LocatorPrxHelper.uncheckedCast(_locatorAdapter.addWithUUID(new VoidLocatorI())); string instanceName = properties.getProperty("IceGridDiscovery.InstanceName"); Ice.Identity id = new Ice.Identity(); id.name = "Locator"; id.category = instanceName.Length > 0 ? instanceName : Guid.NewGuid().ToString(); LocatorI locator = new LocatorI(LookupPrxHelper.uncheckedCast(lookupPrx), properties, instanceName, voidLo); _communicator.setDefaultLocator(Ice.LocatorPrxHelper.uncheckedCast(_locatorAdapter.addWithUUID(locator))); Ice.ObjectPrx lookupReply = _replyAdapter.addWithUUID(new LookupReplyI(locator)).ice_datagram(); locator.setLookupReply(LookupReplyPrxHelper.uncheckedCast(lookupReply)); _replyAdapter.activate(); _locatorAdapter.activate(); }
public LookupReplyI(LocatorI locator) { _locator = locator; }