Skip to content

Commit

Permalink
Added oceanic support, facelift
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-seagrave committed Jun 8, 2022
1 parent 7f6d053 commit 4817929
Show file tree
Hide file tree
Showing 8 changed files with 382 additions and 361 deletions.
3 changes: 3 additions & 0 deletions EasyCPDLC/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 19 additions & 11 deletions EasyCPDLC/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public partial class MainForm : Form
public bool fsConnectionOpen = false;
public int fsuipcErrorCount = 1;

private bool isErrorState = false;

public Random random = new();

readonly private List<Contract> contracts = new();
Expand Down Expand Up @@ -583,15 +585,20 @@ public async Task SendCPDLCMessage(string recipient, string messageType, string
Logger.Debug(String.Format("PACKET SENT: {0} | {1} | {2} | {3} | {4}", recipient, messageType, packetData, true, _write));
var responseString = await response.Content.ReadAsStringAsync();
string printString = responseString.ToString().ToUpper().Trim();

Logger.Debug("RECEIVED: " + responseString);

if (printString.Contains("ERROR"))
{
//handle error here
throw new HttpRequestException();
}
else
{
if(isErrorState)
{
WriteMessage("HOPPIE CONNECTIVITY RESTORED.", "SYSTEM", "SYSTEM");
isErrorState = false;
}

SendingProgress.Invoke(() => SendingProgress.PerformStep());

if (_write && messageType != "poll")
Expand All @@ -610,9 +617,12 @@ public async Task SendCPDLCMessage(string recipient, string messageType, string

catch (Exception e)
{
Logger.Error(String.Format("{0}: {1}", e.GetType().FullName, e.Message));
WriteMessage("ERROR CHECKING FOR NEW MESSAGES. RETRYING...", "SYSTEM", "SYSTEM");

if(!isErrorState)
{
Logger.Error(String.Format("{0}: {1}", e.GetType().FullName, e.Message));
WriteMessage("ERROR CHECKING FOR NEW MESSAGES. THIS IS LIKELY AN ERROR WITH THE HOPPIE NETWORK. THE SYSTEM WILL CONTINUE ATTEMPTING TO CONTACT THE SERVER AND LET YOU KNOW WHEN CONNECTION IS RE-ESTABLISHED.", "SYSTEM", "SYSTEM");
isErrorState = true;
}
SendingProgress.Invoke(() => SendingProgress.Visible = false);
}

Expand All @@ -630,9 +640,9 @@ private CPDLCMessage CreateCPDLCMessage(string _contents, string _type, string _
Text = _type == "SYSTEM" ? "SYSTEM MESSAGE" : _outbound ? String.Format("{1} MESSAGE TO {0}", _recipient, _type.ToUpper()) : String.Format("{1} MESSAGE FROM {0}", _recipient, _type.ToUpper()),
BorderStyle = BorderStyle.None,
TabStop = true,
TabIndex = 0
TabIndex = 0,
Margin = new Padding(0, 3, 0, 0)
};
_message.Margin = new Padding(0, 3, 0, 0);

return _message;
}
Expand Down Expand Up @@ -872,9 +882,6 @@ private Task ADSCParser(string _response, string _sender)

break;

case "EVENTS":
break;

case "CANCEL":
_contract = contracts.Where(x => x.sender == _sender && x.contractLength == responseElements[2]).FirstOrDefault();
if(!_contract.Equals(default(Contract)))
Expand Down Expand Up @@ -978,7 +985,7 @@ private async Task CPDLCParser(string _response, string _sender)
WriteMessage("CURRENT ATS UNIT: " + pendingLogon, "CPDLC", _sender, false, header);
_showUser = false;
}
else if (messageString.StartsWith("CURRENT ATS UNIT"))
else if (messageString.StartsWith("CURRENT ATC UNIT") || messageString.StartsWith("CURRENT ATS UNIT"))
{
_showUser = false;
}
Expand Down Expand Up @@ -1070,6 +1077,7 @@ private async void RetrieveButton_Click(object sender, EventArgs e)

if (!Connected)
{

try
{
using (HttpClient wc = new())
Expand Down
2 changes: 1 addition & 1 deletion EasyCPDLC/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs
LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu
SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAA4AcAAAJNU0Z0AUkBTAMBAQAB
OAEAATgBAAESAQABEgEABP8BCQEACP8BQgFNATYBBAYAATYBBAIAASgDAAFIAwABEgMAAQEBAAEIBQAB
UAEAAVABAAESAQABEgEABP8BCQEACP8BQgFNATYBBAYAATYBBAIAASgDAAFIAwABEgMAAQEBAAEIBQAB
EAEFGAABgAIAAYADAAKAAQABgAMAAYABAAGAAQACgAIAA8ABAAHAAdwBwAEAAfABygGmAQABMwUAATMB
AAEzAQABMwEAAjMCAAMWAQADHAEAAyIBAAMpAQADVQEAA00BAANCAQADOQEAAYABfAH/AQACUAH/AQAB
kwEAAdYBAAH/AewBzAEAAcYB1gHvAQAB1gLnAQABkAGpAa0CAAH/ATMDAAFmAwABmQMAAcwCAAEzAwAC
Expand Down
Loading

0 comments on commit 4817929

Please sign in to comment.