public HttpResponseMessage ClosePost([FromBody] FSUIPCConnect value) { try { FSPFSUIPCConnection.Close(); return(Request.CreateResponse(HttpStatusCode.OK, "Connection Closed")); } catch (Exception ee) { Console.WriteLine(ee.Message); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Error closing connection", ee)); } }
public HttpResponseMessage OpenPost([FromBody] FSUIPCConnect value) { Logger log = LogManager.GetCurrentClassLogger(); try { log.Info("Received OpenFSUIPC Connection call"); ConnectResponse resp = new ConnectResponse(); if (FSPFSUIPCConnection.IsOpen) { log.Info("Connection already is open"); resp.Message = "Connection Opened"; } else { log.Info("Opening connection.."); FSPFSUIPCConnection.Open(); resp.Message = "Connection Opened"; } FSPFSUIPCConnection.AddOffset(15616, Datatype.String, "Connect"); FSPOffset _offset = FSPFSUIPCConnection.Process("Connect").First(); OffsetResponse _resp = OffsetHelpers.setOffsetResponse(_offset); resp.Version = FSPServerV2.Library.Properties.Version.getVersion(); resp.Simulator = FSPFSUIPCConnection.FlightSimVersionConnected.ToString(); resp.Aircraft = _resp.Value; return(Request.CreateResponse(HttpStatusCode.OK, resp)); } catch (Exception ee) { Console.WriteLine(ee.Message); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Connection Error", ee)); //return Request.CreateResponse(HttpStatusCode.OK, "error: " + ee.Message); } }