当前位置: 首页>>代码示例>>C#>>正文


C# NetworkClient.IsConnected方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:wshanshan,项目名称:DDD,代码行数:91,代码来源:Adams+Program.cs


注:本文中的NetworkClient.IsConnected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。