Exemple #1
0
        public Form1()
        {
            InitializeComponent();

            IPEndPoint localEP = new IPEndPoint(System.Net.IPAddress.Any, 49898);

            m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            m_socket.Bind(localEP);

            pReader = new JC2GPSServer.ProcessMemoryReader();
            System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcessesByName("JustCause2");

            if (myProcesses.Length > 0)
            {
                pReader.ReadProcess = myProcesses[0];
                pReader.OpenProcess();

                System.Timers.Timer updateTimer = new System.Timers.Timer();
                updateTimer.Interval            = 500;
                updateTimer.Elapsed            += new ElapsedEventHandler(broadcast);
                updateTimer.SynchronizingObject = this;
                updateTimer.Start();

                System.Timers.Timer checkPostionAndSpeedTimer = new System.Timers.Timer();
                checkPostionAndSpeedTimer.Interval            = 300;
                checkPostionAndSpeedTimer.Elapsed            += new ElapsedEventHandler(checkPositionAndSpeed);
                checkPostionAndSpeedTimer.SynchronizingObject = this;
                checkPostionAndSpeedTimer.Start();
            }
        }
Exemple #2
0
        public Form1()
        {
            InitializeComponent();

            IPEndPoint localEP = new IPEndPoint(System.Net.IPAddress.Any, 49898);
            m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            m_socket.Bind(localEP);

            pReader = new JC2GPSServer.ProcessMemoryReader();
            System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcessesByName("JustCause2");

            if (myProcesses.Length > 0)
            {
                pReader.ReadProcess = myProcesses[0];
                pReader.OpenProcess();

                System.Timers.Timer updateTimer = new System.Timers.Timer();
                updateTimer.Interval = 500;
                updateTimer.Elapsed += new ElapsedEventHandler(broadcast);
                updateTimer.SynchronizingObject = this;
                updateTimer.Start();

                System.Timers.Timer checkPostionAndSpeedTimer = new System.Timers.Timer();
                checkPostionAndSpeedTimer.Interval = 300;
                checkPostionAndSpeedTimer.Elapsed += new ElapsedEventHandler(checkPositionAndSpeed);
                checkPostionAndSpeedTimer.SynchronizingObject = this;
                checkPostionAndSpeedTimer.Start();
            }
        }