private void scConfig_ConnectClicked(object sender, EventArgs e) { scConfig.Visibility = Visibility.Collapsed; sc = new BeatlesBlog.SimConnect.SimConnect(this.Dispatcher); sc.OnRecvException += new BeatlesBlog.SimConnect.SimConnect.RecvExceptionEventHandler(sc_OnRecvException); sc.OnRecvOpen += new BeatlesBlog.SimConnect.SimConnect.RecvOpenEventHandler(sc_OnRecvOpen); sc.OnRecvSimobjectData += new BeatlesBlog.SimConnect.SimConnect.RecvSimobjectDataEventHandler(sc_OnRecvSimobjectData); sc.Open("MovingMapSL", scConfig.ServerName, scConfig.ServerPortInt); }
public void Test() { // hook needed events sc.OnRecvOpen += new BeatlesBlog.SimConnect.SimConnect.RecvOpenEventHandler(sc_OnRecvOpen); sc.OnRecvException += new BeatlesBlog.SimConnect.SimConnect.RecvExceptionEventHandler(sc_OnRecvException); sc.OnRecvEvent += new BeatlesBlog.SimConnect.SimConnect.RecvEventEventHandler(sc_OnRecvEvent); sc.OnRecvWeatherObservation += new BeatlesBlog.SimConnect.SimConnect.RecvWeatherObservationEventHandler(sc_OnRecvWeatherObservation); sc.OnRecvSimobjectData += new BeatlesBlog.SimConnect.SimConnect.RecvSimobjectDataEventHandler(sc_OnRecvSimobjectData); sc.OnRecvQuit += new BeatlesBlog.SimConnect.SimConnect.RecvQuitEventHandler(sc_OnRecvQuit); sc.OnRecvAssignedObjectId += new BeatlesBlog.SimConnect.SimConnect.RecvAssignedObjectIdEventHandler(sc_OnRecvAssignedObjectId); // only uncomment one of the sc.Open lines below // comment this if and all the local versions of the sc.Open if using a test remote connection if (BeatlesBlog.SimConnect.SimConnect.IsLocalRunning()) { // allow attempt a local connection if one appears to be running // make local pipe connection (default local mode) sc.Open("SimConnectTest"); // make local IPv4 connection (any of the below are valid) //sc.Open("SimConnectTest", null, 0, System.Net.Sockets.AddressFamily.InterNetwork); //sc.Open("SimConnectTest", "", 0, System.Net.Sockets.AddressFamily.InterNetwork); //sc.Open("SimConnectTest", "localhost", 0, System.Net.Sockets.AddressFamily.InterNetwork); //sc.Open("SimConnectTest", "127.0.0.1", 0, System.Net.Sockets.AddressFamily.InterNetwork); // make local IPv6 connection (any of the below are valid) //sc.Open("SimConnectTest", null, 0, System.Net.Sockets.AddressFamily.InterNetworkV6); //sc.Open("SimConnectTest", "", 0, System.Net.Sockets.AddressFamily.InterNetworkV6); //sc.Open("SimConnectTest", "localhost", 0, System.Net.Sockets.AddressFamily.InterNetworkV6); //sc.Open("SimConnectTest", "::0", 0, System.Net.Sockets.AddressFamily.InterNetworkV6); } else { // make remote IPv4 connection //sc.Open("SimConnectTest", "winxpsp3dt", 4504, System.Net.Sockets.AddressFamily.InterNetwork); // make remote IPv6 connection //sc.Open("SimConnectTest", "vista64vm", 4506, System.Net.Sockets.AddressFamily.InterNetworkV6); // comment these 3 lines out if using a test remote connection Console.WriteLine("No Local SimConnect Instance available. Press return to exit."); Console.ReadLine(); return; } // cause mainline of program to wait until exit option is chosen from in-game menu, or game exits exitEvent.WaitOne(); }