本文整理汇总了C#中NetworkClient.IsConnected方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkClient.IsConnected方法的具体用法?C# NetworkClient.IsConnected怎么用?C# NetworkClient.IsConnected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkClient
的用法示例。
在下文中一共展示了NetworkClient.IsConnected方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//[STAThread]
static void Main(string[] args)
{
string hostname = args[0];
int port = Int32.Parse(args[1]);
string simModelName = args[2];
SimulationModelReader smr = new SimulationModelReader();
SimulationModelInfo simModelInfo = smr.readModel(simModelName);
SimulationEventDistributor dist = new SimulationEventDistributor(ref simModelInfo);
SimulationEventDistributorClient cc = new SimulationEventDistributorClient();
dist.RegisterClient(ref cc);
cc.Subscribe("ALL");
ScenarioReader scenarioReader = new ScenarioReader();
QueueManager queueManager = QueueManager.UniqueInstance();
c = new NetworkClient();
c.Connect(hostname, port);
EventListener myEL = EventListener.UniqueInstance(c);
int t = 0;
int dt = simModelInfo.simulationExecutionModel.updateFrequency;
SimulationEvent tick = SimulationEventFactory.BuildEvent(ref simModelInfo, "TimeTick");
((IntegerValue)tick["Time"]).value = t;
ConsoleKeyInfo cki;
//Console.TreatControlCAsInput = false; //This explodes my code for some reason, but is in Gabe's client code and works fine, what does it do?
Console.CancelKeyPress += new ConsoleCancelEventHandler(MyExitHandler);
List<SimulationEvent> events = null;
while (c.IsConnected() && queueManager.count() > 0)
{
//Read incoming events queue
//if any events deal with a conditional event, remove the conditional
//event from the conditional list, and place it onto the event queue
//if a unit dies, remove them from the event queue and condition list
while (c.IsConnected() && !(queueManager.eventsAtTime(t)))
{
events = c.GetEvents();
foreach (SimulationEvent e in events)
{
if (e.eventType == "MoveDone")
c.PutEvent(myEL.MoveDoneReceived(e, simModelInfo, tick));
System.Console.WriteLine(SimulationEventFactory.XMLSerialize(e));
}
((IntegerValue)tick["Time"]).value = t;
c.PutEvent(tick);
//Console.WriteLine("Sending...");
//Console.WriteLine(SimulationEventFactory.XMLSerialize(tick));
Thread.Sleep(dt);
t += dt;
}
if (c.IsConnected())
{
QueueManager.sendEventsAtTime(t, c);
((IntegerValue)tick["Time"]).value = t;
c.PutEvent(tick);
//Console.WriteLine("Sending...");
//Console.WriteLine(SimulationEventFactory.XMLSerialize(e));
t += dt;
}
}
while (c.IsConnected())
{
((IntegerValue)tick["Time"]).value = t;
c.PutEvent(tick);
//Console.WriteLine("Sending...");
//Console.WriteLine(SimulationEventFactory.XMLSerialize(tick));
Thread.Sleep(dt);
t += dt;
}
}