本文整理汇总了C#中IScene.AddCommandHandler方法的典型用法代码示例。如果您正苦于以下问题:C# IScene.AddCommandHandler方法的具体用法?C# IScene.AddCommandHandler怎么用?C# IScene.AddCommandHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IScene
的用法示例。
在下文中一共展示了IScene.AddCommandHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public void Start(IScene scene)
{
IPAddress bindAddress = IPAddress.Any;
int port = DEFAULT_UDP_PORT;
bool allowAlternatePort = true;
IConfig config = scene.Config.Configs["LindenRegion"];
if (config != null)
{
port = config.GetInt("Port", DEFAULT_UDP_PORT);
allowAlternatePort = config.GetBoolean("AllowAlternatePort", true);
}
config = scene.Config.Configs["LLUDP"];
if (config != null)
{
IPAddress.TryParse(config.GetString("BindAddress", "0.0.0.0"), out bindAddress);
IPAddress.TryParse(config.GetString("MasqueradeAddress", String.Empty), out m_masqAddress);
}
if (bindAddress.Equals(IPAddress.Any))
bindAddress = Util.GetLocalInterface();
IScheduler scheduler = scene.Simian.GetAppModule<IScheduler>();
if (scheduler == null)
{
m_log.Error("Cannot start LLUDP server without an IScheduler");
throw new InvalidOperationException();
}
if (allowAlternatePort && m_nextUnusedPort != 0)
port = m_nextUnusedPort;
m_udpServer = new LLUDPServer(this, scene, bindAddress, port, scene.Config, scheduler);
// Loop until we successfully bind to a port or run out of options
while (true)
{
//m_log.Debug("Trying to bind LLUDP server to " + bindAddress + ":" + port);
try
{
m_udpServer.Address = bindAddress;
m_udpServer.Port = port;
m_udpServer.Start();
m_log.Info("Bound LLUDP server to " + bindAddress + ":" + port);
m_nextUnusedPort = port + 1;
IPAddress address = m_masqAddress == null ? bindAddress : m_masqAddress;
scene.ExtraData["ExternalAddress"] = OSD.FromString(address.ToString());
scene.ExtraData["ExternalPort"] = OSD.FromInteger(port);
break;
}
catch (System.Net.Sockets.SocketException)
{
if (allowAlternatePort)
{
++port;
}
else
{
m_log.Error("Failed to bind LLUDP server to port " + port);
break;
}
}
catch (Exception ex)
{
m_log.Error("Failed to bind LLUDP server to any port: " + ex.Message);
break;
}
}
scene.AddCommandHandler("packetlog", PacketLogCommandHandler);
}