Example #1
0
        public void Initialize()
        {
            SimulatorModules _Modules = new SimulatorModules();

            _Modules.Time_Available            = false;  // The plug-in knows the session time.
            _Modules.Track_Coordinates         = true;
            _Modules.Track_MapFile             = false;
            _Modules.Times_LapsBasic           = false;
            _Modules.Times_LastSectors         = true;
            _Modules.Times_History_LapTimes    = false;
            _Modules.Times_History_SectorTimes = false;
            _Modules.Engine_Power      = false;
            _Modules.Engine_PowerCurve = false;
            _Modules.Aero_Drag         = false;
            Modules = _Modules;

            Drivers = new NetworkDrivers();
            Player  = new NetworkDriverPlayer();
            Session = new NetworkSession();
            Garage  = new NetworkGarage();
            Memory  = null;

            Telemetry.m.Net.Change += Net_Change;
        }
Example #2
0
        public void Initialize()
        {
            SimulatorModules _Modules = new SimulatorModules();
            _Modules.Time_Available = false;             // The plug-in knows the session time.
            _Modules.Track_Coordinates = true;
            _Modules.Track_MapFile = false;
            _Modules.Times_LapsBasic = false;
            _Modules.Times_LastSectors = true;
            _Modules.Times_History_LapTimes = false;
            _Modules.Times_History_SectorTimes = false;
            _Modules.Engine_Power = false;
            _Modules.Engine_PowerCurve = false;
            _Modules.Aero_Drag = false;
            Modules = _Modules;

            Drivers = new NetworkDrivers();
            Player = new NetworkDriverPlayer();
            Session = new NetworkSession();
            Garage = new NetworkGarage();
            Memory = null;

            Telemetry.m.Net.Change += Net_Change;
        }
        private void DataCreator()
        {
            int SecTimer = 0;

            while (_mServer.Running)
            {
                SecTimer++;
                try
                {
                    NetworkPacket packet = new NetworkPacket();
                    packet.Type = NetworkTypes.SIMULATOR;
                    if (!Telemetry.m.Active_Sim)
                    {
                        List <string> Sims = new List <string>();
                        Telemetry.m.Sims.Sims.ForEach(x => Sims.Add(x.ProcessName));
                        NetworkStateReport report = new NetworkStateReport(NetworkAppState.WAITING_SIM, Sims);
                        packet.Data = ByteMethods.SerializeToBytes(report);
                        _mServer.Write(packet);
                    }
                    else if (!Telemetry.m.Active_Session)
                    {
                        NetworkStateReport report = new NetworkStateReport(NetworkAppState.WAITING_SESSION, Telemetry.m.Sim.Name, Telemetry.m.Sim.ProcessName);
                        packet.Data = ByteMethods.SerializeToBytes(report);
                        _mServer.Write(packet);
                    }

                    // TODO: Add packet for game.
                    if (Telemetry.m.Active_Sim && Telemetry.m.Active_Session)
                    {
                        NetworkStateReport report = new NetworkStateReport(NetworkAppState.RUNNING, Telemetry.m.Sim.Name, Telemetry.m.Sim.ProcessName);
                        packet.Data = ByteMethods.SerializeToBytes(report);
                        _mServer.Write(packet);

                        packet.Type = NetworkTypes.SESSION;
                        packet.Data = ByteMethods.SerializeToBytes(NetworkSession.Create(Telemetry.m.Sim.Session));
                        _mServer.Write(packet);

                        packet.Type = NetworkTypes.DRIVER;
                        packet.Data = ByteMethods.SerializeToBytes(NetworkDrivers.Create(Telemetry.m.Sim.Drivers));
                        _mServer.Write(packet);

                        packet.Type = NetworkTypes.PLAYER;
                        packet.Data = ByteMethods.SerializeToBytes(NetworkDriverPlayer.Create(Telemetry.m.Sim.Player));
                        _mServer.Write(packet);

                        if (SecTimer % (5 * Bandwidth) == 0 && Telemetry.m.Track.Route != null) // every 5 seconds
                        {
                            // Send complete track route
                            packet.Type = NetworkTypes.TRACKMAP;
                            packet.Data = ByteMethods.SerializeToBytes(Telemetry.m.Track.Route);
                            _mServer.Write(packet);

                            packet.Type = NetworkTypes.TRACK;
                            NetworkTrackInformation trackInfo = new NetworkTrackInformation();
                            trackInfo.Type     = Telemetry.m.Track.Type;
                            trackInfo.Location = Telemetry.m.Track.Location;
                            trackInfo.Name     = Telemetry.m.Track.Name;
                            packet.Data        = ByteMethods.SerializeToBytes(trackInfo);
                            _mServer.Write(packet);
                        }
                    }
                }
                catch (Exception ex)
                {
                }
                Thread.Sleep(1000 / Bandwidth);
            }
        }