コード例 #1
0
        //assuming this SA is a manager it will broadcast the simulation data needed to connect to a simulation
        public void broadCastNewSimulation(object source, ElapsedEventArgs e)
        {
            //build XML sim setup message
            XMLSimSetupNotification setup = new XMLSimSetupNotification();
            setup.SimulationId = _appConfig.SIM_ID;
            setup.SimulationName = _appConfig.SIM_NAME;
            setup.ManagerIp = _appConfig.LOCAL_IP_ADDRESS;
            setup.ManagerPort = SimulationRunningConfig.TCP_SIMULATION_APP_PORT;
            setup.ManagerId = _appConfig.APP_ID;
            setup.Secure = false;
            //setup.Password = "******"
            setup.SimulationDescription = _appConfig.SIM_DESCRIPTION;

            //wrap XML message with DEM header and send out
            MessageWrapper wrap = new MessageWrapper();
            wrap.ApplicationId = _appConfig.APP_ID;
            wrap.ApplicationRole = _appConfig.APP_ROLE;
            wrap.MessageType = MessageBase.MESSAGE_SIM_SETUP;
            wrap.Message = setup;

            //setup.printToConsole();

            NetworkConnection netPipe = new NetworkConnection(_appConfig);
            netPipe.sendUdpBroadcast(wrap.toXmlString(), SimulationRunningConfig.UDP_NETWORK_BROADCAST_ADDRESS, SimulationRunningConfig.UDP_SIMULATION_APP_PORT);
        }
コード例 #2
0
        private void requestJoinSimulation(XMLSimSetupNotification simulation)
        {
            XMLSimJoinRequest joinRequest = new XMLSimJoinRequest();
            joinRequest.ParticipantId = _appConfig.APP_ID;
            joinRequest.ParticipantIp = _appConfig.LOCAL_IP_ADDRESS;

            //wrap XML message with Communications header and send out
            MessageWrapper wrap = new MessageWrapper();
            wrap.ApplicationId = _appConfig.APP_ID;
            wrap.ApplicationRole = _appConfig.APP_ROLE;
            wrap.MessageType = MessageBase.MESSAGE_JOIN_REQUEST;
            wrap.Message = joinRequest;

            System.Console.WriteLine("Sending: " + wrap.toXmlString());

            NetworkConnection netPipe = new NetworkConnection(_appConfig);
            netPipe.sendTcpDataConnectionRequest(wrap.toXmlString(), simulation.ManagerIp, simulation.ManagerPort);
        }