本文整理汇总了C#中Ice.createObjectAdapterWithEndpoints方法的典型用法代码示例。如果您正苦于以下问题:C# Ice.createObjectAdapterWithEndpoints方法的具体用法?C# Ice.createObjectAdapterWithEndpoints怎么用?C# Ice.createObjectAdapterWithEndpoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ice
的用法示例。
在下文中一共展示了Ice.createObjectAdapterWithEndpoints方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Server
public Server(Ice.Communicator iceCommunicator, string clientEndpoint, Murmur.ServerPrx proxy, string name)
{
Users.CollectionChanged += OnUsersCollectionChanged;
ServerProxy = proxy;
Name = name;
try {
var servant = new ServerCallback(this);
var adapter = iceCommunicator.createObjectAdapterWithEndpoints("", clientEndpoint);
var servantProxy = adapter.addWithUUID(servant);
ServerCallbackProxy = Murmur.ServerCallbackPrxHelper.checkedCast(servantProxy);
adapter.activate();
// TODO: Allow user to provide Ice secret
var context = new Dictionary<string, string>();
context["secret"] = "";
ServerProxy.ice_getConnection().setAdapter(adapter);
ServerProxy.addCallback(ServerCallbackProxy, context);
ServerProxy.begin_getUsers().whenCompleted(
users => {
CompleteGetUsers(users);
},
e => {
System.Diagnostics.Debug.WriteLine("Could not get user dictionary for {0}: {1}", Name, e.ToString());
}
);
} catch (Ice.Exception e) {
System.Diagnostics.Debug.WriteLine("Error talking to {0}: {1}", Name, e.ToString());
}
}
示例2: createAdapter
public static Ice.ObjectAdapter createAdapter(
Ice.Communicator ic, string adapterName, uint port)
{
instance = ic.createObjectAdapterWithEndpoints(
adapterName, "default -p " + port);
instance.activate();
return instance;
}
示例3: allTests
//.........这里部分代码省略.........
//
com.trace("testCat2", "A");
com.trace("testCat", "trace3");
com.trace("testCat2", "B");
messageTypes = new Ice.LogMessageType[]{Ice.LogMessageType.ErrorMessage, Ice.LogMessageType.TraceMessage};
string[] categories = {"testCat"};
logMessages = logger.getLog(messageTypes, categories, -1, out prefix);
test(logMessages.Length == 5);
test(prefix.Equals("NullLogger"));
foreach(var msg in logMessages)
{
test(msg.type == Ice.LogMessageType.ErrorMessage ||
(msg.type == Ice.LogMessageType.TraceMessage && msg.traceCategory.Equals("testCat")));
}
//
// Same, but limited to last 2 messages (trace3 + error3)
//
com.error("error3");
logMessages = logger.getLog(messageTypes, categories, 2, out prefix);
test(logMessages.Length == 2);
test(prefix.Equals("NullLogger"));
test(logMessages[0].message.Equals("trace3"));
test(logMessages[1].message.Equals("error3"));
//
// Now, test RemoteLogger
//
Ice.ObjectAdapter adapter =
communicator.createObjectAdapterWithEndpoints("RemoteLoggerAdapter", "tcp -h localhost");
RemoteLoggerI remoteLogger = new RemoteLoggerI();
Ice.RemoteLoggerPrx myProxy = Ice.RemoteLoggerPrxHelper.uncheckedCast(adapter.addWithUUID(remoteLogger));
adapter.activate();
//
// No filtering
//
logMessages = logger.getLog(null, null, -1, out prefix);
remoteLogger.checkNextInit(prefix, logMessages);
logger.attachRemoteLogger(myProxy, null, null, -1);
remoteLogger.wait(1);
remoteLogger.checkNextLog(Ice.LogMessageType.TraceMessage, "rtrace", "testCat");
remoteLogger.checkNextLog(Ice.LogMessageType.WarningMessage, "rwarning", "");
remoteLogger.checkNextLog(Ice.LogMessageType.ErrorMessage, "rerror", "");
remoteLogger.checkNextLog(Ice.LogMessageType.PrintMessage, "rprint", "");
com.trace("testCat", "rtrace");
com.warning("rwarning");
com.error("rerror");
com.print("rprint");
remoteLogger.wait(4);
test(logger.detachRemoteLogger(myProxy));
test(!logger.detachRemoteLogger(myProxy));
//
示例4: allTests
allTests(Ice.Communicator communicator)
{
Ice.ObjectAdapter oa = communicator.createObjectAdapterWithEndpoints("MyOA", "tcp -h localhost");
oa.activate();
Ice.Object servant = new MyObjectI();
//
// Register default servant with category "foo"
//
oa.addDefaultServant(servant, "foo");
//
// Start test
//
Console.Out.Write("testing single category... ");
Console.Out.Flush();
Ice.Object r = oa.findDefaultServant("foo");
test(r == servant);
r = oa.findDefaultServant("bar");
test(r == null);
Ice.Identity identity = new Ice.Identity();
identity.category = "foo";
string[] names = new string[] { "foo", "bar", "x", "y", "abcdefg" };
Test.MyObjectPrx prx = null;
for(int idx = 0; idx < 5; ++idx)
{
identity.name = names[idx];
prx = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
prx.ice_ping();
test(prx.getName() == names[idx]);
}
identity.name = "ObjectNotExist";
prx = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
try
{
prx.ice_ping();
test(false);
}
catch(Ice.ObjectNotExistException)
{
// Expected
}
try
{
prx.getName();
test(false);
}
catch(Ice.ObjectNotExistException)
{
// Expected
}
identity.name = "FacetNotExist";
prx = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
try
{
prx.ice_ping();
test(false);
}
catch(Ice.FacetNotExistException)
{
// Expected
}
try
{
prx.getName();
test(false);
}
catch(Ice.FacetNotExistException)
{
// Expected
}
identity.category = "bar";
for(int idx = 0; idx < 5; idx++)
{
identity.name = names[idx];
prx = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
try
{
prx.ice_ping();
test(false);
}
catch(Ice.ObjectNotExistException)
{
// Expected
}
try
{
//.........这里部分代码省略.........
示例5: allTests
public static TestIntfPrx allTests(Ice.Communicator communicator)
{
Console.Out.Write("testing stringToProxy... ");
Console.Out.Flush();
string @ref = "test:default -p 12010";
Ice.ObjectPrx @base = communicator.stringToProxy(@ref);
test(@base != null);
Console.Out.WriteLine("ok");
Console.Out.Write("testing checked cast... ");
Console.Out.Flush();
TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base);
test(obj != null);
test(obj.Equals(@base));
Console.Out.WriteLine("ok");
{
Console.Out.Write("creating/destroying/recreating object adapter... ");
Console.Out.Flush();
Ice.ObjectAdapter adapter =
communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default");
try
{
communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default");
test(false);
}
catch(Ice.AlreadyRegisteredException)
{
}
adapter.destroy();
//
// Use a different port than the first adapter to avoid an "address already in use" error.
//
adapter = communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default");
adapter.destroy();
Console.Out.WriteLine("ok");
}
Console.Out.Write("creating/activating/deactivating object adapter in one operation... ");
Console.Out.Flush();
obj.transient();
Console.Out.WriteLine("ok");
Console.Out.Write("deactivating object adapter in the server... ");
Console.Out.Flush();
obj.deactivate();
Console.Out.WriteLine("ok");
Console.Out.Write("testing whether server is gone... ");
Console.Out.Flush();
try
{
obj.ice_ping();
throw new System.ApplicationException();
}
catch(Ice.LocalException)
{
Console.Out.WriteLine("ok");
}
return obj;
}
示例6: allTests
//.........这里部分代码省略.........
}
catch(Base)
{
//
// For the 1.0 encoding, the unknown exception is sliced to Base.
//
test(testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0));
}
catch(Ice.UnknownUserException)
{
//
// A MarshalException is raised for the compact format because the
// most-derived type is unknown and the exception cannot be sliced.
//
test(!testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0));
}
catch(Ice.OperationNotExistException)
{
}
catch(Exception)
{
test(false);
}
}
WriteLine("ok");
//
// No server side in Silverlight
//
#if !SILVERLIGHT
Write("preserved exceptions... ");
Flush();
{
Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("Relay", "default");
RelayPrx relay = RelayPrxHelper.uncheckedCast(adapter.addWithUUID(new RelayI()));
adapter.activate();
try
{
testPrx.relayKnownPreservedAsBase(relay);
test(false);
}
catch(KnownPreservedDerived ex)
{
test(ex.b.Equals("base"));
test(ex.kp.Equals("preserved"));
test(ex.kpd.Equals("derived"));
}
catch(Ice.OperationNotExistException)
{
}
catch(Exception)
{
test(false);
}
try
{
testPrx.relayKnownPreservedAsKnownPreserved(relay);
test(false);
}
catch(KnownPreservedDerived ex)
{
test(ex.b.Equals("base"));
test(ex.kp.Equals("preserved"));
test(ex.kpd.Equals("derived"));
示例7: allTests
//.........这里部分代码省略.........
WriteLine("ok");
Write("testing proxy from server after shutdown... ");
Flush();
hello = obj.getReplicatedHello();
obj.shutdown();
manager.startServer();
hello.sayHello();
WriteLine("ok");
Write("testing object migration... ");
Flush();
hello = HelloPrxHelper.checkedCast(communicator.stringToProxy("hello"));
obj.migrateHello();
hello.ice_getConnection().close(false);
hello.sayHello();
obj.migrateHello();
hello.sayHello();
obj.migrateHello();
hello.sayHello();
WriteLine("ok");
Write("testing locator encoding resolution... ");
Flush();
hello = HelloPrxHelper.checkedCast(communicator.stringToProxy("hello"));
count = locator.getRequestCount();
communicator.stringToProxy("[email protected]").ice_encodingVersion(Ice.Util.Encoding_1_1).ice_ping();
test(count == locator.getRequestCount());
communicator.stringToProxy("[email protected]").ice_encodingVersion(Ice.Util.Encoding_1_0).ice_ping();
test(++count == locator.getRequestCount());
communicator.stringToProxy("test -e [email protected]").ice_ping();
test(++count == locator.getRequestCount());
WriteLine("ok");
Write("shutdown server... ");
Flush();
obj.shutdown();
WriteLine("ok");
Write("testing whether server is gone... ");
Flush();
try
{
obj2.ice_ping();
test(false);
}
catch(Ice.LocalException)
{
}
try
{
obj3.ice_ping();
test(false);
}
catch(Ice.LocalException)
{
}
try
{
obj5.ice_ping();
test(false);
}
catch(Ice.LocalException)
{
}
WriteLine("ok");
#if !SILVERLIGHT
Write("testing indirect proxies to collocated objects... ");
Flush();
//
// Set up test for calling a collocated object through an
// indirect, adapterless reference.
//
Ice.Properties properties = communicator.getProperties();
properties.setProperty("Ice.PrintAdapterReady", "0");
Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("Hello", "default");
adapter.setLocator(locator);
Ice.Identity id = new Ice.Identity();
id.name = Guid.NewGuid().ToString();
registry.addObject(adapter.add(new HelloI(), id));
adapter.activate();
HelloPrx helloPrx = HelloPrxHelper.checkedCast(
communicator.stringToProxy("\"" + communicator.identityToString(id) + "\""));
test(helloPrx.ice_getConnection() == null);
adapter.deactivate();
WriteLine("ok");
Write("shutdown server manager... ");
Flush();
manager.shutdown();
WriteLine("ok");
#else
manager.shutdown();
#endif
}