Skip to content

Commit

Permalink
feat(integration): Introduce integration and event sharing with third…
Browse files Browse the repository at this point in the history
…-party plugins (#303)

* Add Interface For Outbound Message

* Fix Comment

* Add Message Targets

* Add Equality Operator

* Add More Interfaces

* Start Integration Guide

* Start Winsock Implementation

* Try More Things

* Server Works

* Get Receive Messages Back, Nice

* Fix Styling

* Add Inbound Message Processing

* Fix Weird Binary File

* Fix Compilation

* Fixing Tests

* Style

* Finish Initialisation Manager Test

* Tidy Up

* Inbound Message Processor Test

* All The Tests

* Add Initialisation Failure Response

* Update Docs

* Make The Build Stricter

* Use Higher Order Functions

* feat(integration): Allow external apps to view handoff frequencies and intention codes (#305)

* Implement Intention Code Update Events

* Add Handoff Events
  • Loading branch information
AndyTWF authored Jul 26, 2021
1 parent 585ef54 commit 739930e
Show file tree
Hide file tree
Showing 91 changed files with 4,438 additions and 126 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:

# Run the build and tests
- name: Run Build
run: msbuild msvc/UKControllerPlugin.sln /verbosity:minimal /property:Configuration=Release -m
run: msbuild msvc/UKControllerPlugin.sln /verbosity:minimal /property:Configuration=Release -m /warnaserror

- name: Run Tests
run: ".\\bin\\Release\\UKControllerPluginTest.exe"
Expand Down
16 changes: 16 additions & 0 deletions docs/IntegrationGuide/Features/DepartureHandoffs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Departure Handoff Frequencies

## Events

### Frequency Updated

```JSON
{
"type": "departure_frequency_updated",
"version": 1,
"data": {
"callsign": "BAW123",
"frequency": "129.420",
}
}
```
6 changes: 6 additions & 0 deletions docs/IntegrationGuide/Features/Index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Feature Integrations

This is the index to all feature integrations provided by the UK Controller Plugin.

- [Intention Codes](IntentionCode.md)
- [Departure Handoff Frequencies](DepartureHandoffs.md)
19 changes: 19 additions & 0 deletions docs/IntegrationGuide/Features/IntentionCode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Intention Codes

## Events

### Code Updated

```JSON
{
"type": "intention_code_updated",
"version": 1,
"data": {
"callsign": "BAW123",
"exit_point": "REDFA",
"code": "C2",
}
}
```

In the event that an aircraft will not be exiting the FIR, the `exit_point` shall be set as `null`.
68 changes: 68 additions & 0 deletions docs/IntegrationGuide/Initialisation/Initialisation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Initialisation

Once a prospective client has successfully established a connection with the UK Controller Plugin, the next expected
message will be that of initialisation. A client will not be able to send to or receive from the UK Controller Plugin
any data until this has been completed.

## The initialisation message

The initialisation message is structured as follows.

```JSON
{
"type": "initialise",
"version": 1,
"data": {
"integration_name": "string",
"integration_version": "string",
"event_subscriptions": [
{
"type": "string",
"version": "integer"
},
{
"type": "string",
"version": "integer"
}
]
}
}
```

The integration name and version allows for appropriate logging to take place, in order to help developers on both
sides to debug any issues.

The message id is a string that identifies this message to the plugin, which will be used in order to respond.

## The initialisation response

### Success

After a successful initialisation, the following response will be returned.

```JSON
{
"type": "initialisation_success",
"version": 1,
"data": {
"ukcp_version": "string"
}
}
```

Note, that until this response has been sent, the plugin will not action any other messages received from the integration.

**Any messages received before the initialisation response has been sent will be ignored**.

### Failure

After a failed initialisation, the following response will be returned.
```JSON
{
"type": "initialisation_failure",
"version": 1,
"errors": [
"string"
]
}
```
12 changes: 12 additions & 0 deletions docs/IntegrationGuide/IntegrationGuide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Integration Guide

The UK Controller Plugin provides a means of sharing its functionality with other software used by controllers on
VATSIM. This is achieved via a means to connect to the plugin and a JSON message passing protocol, allowing the plugin
to notify listeners of pertinent events or perform actions on their behalf.

## Contents

- [Overview](Overview/Overview.md)
- [Initialisation](Initialisation/Initialisation.md)
- [Standard Message Responses](Responses/StandardResponses.md)
- [Feature Messages Index](Features/Index.md)
36 changes: 36 additions & 0 deletions docs/IntegrationGuide/Overview/Overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Overview

The integration protocol consists of JSON messages, passed back and forth over communication channels.

## Message Format

All messages follow the same basic JSON format, containing a message type and a version. Some messages will also require
a unique message identifier, which will allow for a response to be returned.

This is the basic format of a message:

```JSON
{
"type": "event_type",
"version": 1,
"data": {
"some_field": "some_value"
}
}
```

## Communication Channels

There is currently one communication channel available for integration.

### Windows Sockets

The UK Controller Plugin listens for connecting integrations via **TCP port 52814** using Windows Sockets. Once a client
has connected, the plugin expects to receive an initialisation message (covered later in this guide) which lets it
know what events the integration wishes to receive.

As TCP can break up any messages into arbitrary sized chunks for the purpose of transmission, it is necessary for each
message to be delimited with a special character so that the boundaries of each message can be determined.

As control characters are not valid in well-formed JSON, the Unit Separator character `\0x1F` is used to delimited
individual JSON messages.
29 changes: 29 additions & 0 deletions docs/IntegrationGuide/Responses/StandardResponses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Standard Message Responses

This section provides details of generic responses to messages provided by the UK Controller Plugin.

## Success

This response will be sent following a successful action performed as a result of a message from the client.

```JSON
{
"type": "action_success",
"version": 1,
}
```

## Failure

This response will be sent if the plugin fails to perform an action following a message from the client.

```JSON
{
"type": "action_failure",
"version": 1,
"errors": [
"string",
"string"
]
}
```
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ for example, stand allocations.
- [Getting help](UserGuide/GettingHelp/Help.md)
- [Changelog](UserGuide/Changelog/Changelog.md)
- [Web API Changelog](https://github.com/VATSIM-UK/uk-controller-api/blob/main/docs/CHANGELOG.md)
- [External Integration Guide](IntegrationGuide/IntegrationGuide.md)
39 changes: 37 additions & 2 deletions msvc/UKControllerPlugin/UKControllerPlugin.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<ClInclude Include="..\..\src\handoff\HandoffCollection.h" />
<ClInclude Include="..\..\src\handoff\HandoffCollectionFactory.h" />
<ClInclude Include="..\..\src\handoff\HandoffEventHandler.h" />
<ClInclude Include="..\..\src\handoff\HandoffFrequencyUpdatedMessage.h" />
<ClInclude Include="..\..\src\handoff\HandoffModule.h" />
<ClInclude Include="..\..\src\historytrail\AircraftHistoryTrail.h" />
<ClInclude Include="..\..\src\historytrail\HistoryTrailData.h" />
Expand Down Expand Up @@ -150,16 +151,34 @@
<ClInclude Include="..\..\src\hold\MinStackHoldLevelRestriction.h" />
<ClInclude Include="..\..\src\hold\MinStackHoldLevelRestrictionSerializer.h" />
<ClInclude Include="..\..\src\hold\PublishedHoldCollection.h" />
<ClInclude Include="..\..\src\initialaltitude\CompareInitialAltitudes.h" />
<ClInclude Include="..\..\src\initialaltitude\InitialAltitudeData.h" />
<ClInclude Include="..\..\src\initialaltitude\InitialAltitudeEventHandler.h" />
<ClInclude Include="..\..\src\initialaltitude\InitialAltitudeModule.h" />
<ClInclude Include="..\..\src\initialheading\InitialHeadingEventHandler.h" />
<ClInclude Include="..\..\src\initialheading\InitialHeadingModule.h" />
<ClInclude Include="..\..\src\integration\ClientInitialisationManager.h" />
<ClInclude Include="..\..\src\integration\Connection.h" />
<ClInclude Include="..\..\src\integration\DummyOutboundIntegrationMessageHandler.h" />
<ClInclude Include="..\..\src\integration\ExternalMessageEventHandler.h" />
<ClInclude Include="..\..\src\integration\ExternalMessageHandlerInterface.h" />
<ClInclude Include="..\..\src\integration\HiddenWindow.h" />
<ClInclude Include="..\..\src\integration\InboundIntegrationMessageHandler.h" />
<ClInclude Include="..\..\src\integration\InboundIntegrationMessageProcessor.h" />
<ClInclude Include="..\..\src\integration\InboundMessage.h" />
<ClInclude Include="..\..\src\integration\InitialisationFailureMessage.h" />
<ClInclude Include="..\..\src\integration\InitialisationSuccessMessage.h" />
<ClInclude Include="..\..\src\integration\IntegrationClient.h" />
<ClInclude Include="..\..\src\integration\IntegrationClientManager.h" />
<ClInclude Include="..\..\src\integration\IntegrationConnection.h" />
<ClInclude Include="..\..\src\integration\IntegrationModule.h" />
<ClInclude Include="..\..\src\integration\IntegrationPersistenceContainer.h" />
<ClInclude Include="..\..\src\integration\IntegrationServer.h" />
<ClInclude Include="..\..\src\integration\MessageType.h" />
<ClInclude Include="..\..\src\integration\MessageInterface.h" />
<ClInclude Include="..\..\src\integration\OutboundIntegrationEventHandler.h" />
<ClInclude Include="..\..\src\integration\OutboundIntegrationMessageHandler.h" />
<ClInclude Include="..\..\src\integration\SocketConnection.h" />
<ClInclude Include="..\..\src\integration\SocketInterface.h" />
<ClInclude Include="..\..\src\integration\SocketWrapper.h" />
<ClInclude Include="..\..\src\intention\AirfieldGroup.h" />
<ClInclude Include="..\..\src\intention\AmsterdamAirfieldGroup.h" />
<ClInclude Include="..\..\src\intention\BrusselsAirfieldGroup.h" />
Expand All @@ -171,6 +190,7 @@
<ClInclude Include="..\..\src\intention\IntentionCodeFactory.h" />
<ClInclude Include="..\..\src\intention\IntentionCodeGenerator.h" />
<ClInclude Include="..\..\src\intention\IntentionCodeModule.h" />
<ClInclude Include="..\..\src\intention\IntentionCodeUpdatedMessage.h" />
<ClInclude Include="..\..\src\intention\SectorExitPoint.h" />
<ClInclude Include="..\..\src\intention\SectorExitPointEtrat.h" />
<ClInclude Include="..\..\src\intention\SectorExitPointKonan.h" />
Expand Down Expand Up @@ -406,6 +426,7 @@
<ClCompile Include="..\..\src\handoff\HandoffCollection.cpp" />
<ClCompile Include="..\..\src\handoff\HandoffCollectionFactory.cpp" />
<ClCompile Include="..\..\src\handoff\HandoffEventHandler.cpp" />
<ClCompile Include="..\..\src\handoff\HandoffFrequencyUpdatedMessage.cpp" />
<ClCompile Include="..\..\src\handoff\HandoffModule.cpp" />
<ClCompile Include="..\..\src\historytrail\AircraftHistoryTrail.cpp" />
<ClCompile Include="..\..\src\historytrail\HistoryTrailDialog.cpp" />
Expand Down Expand Up @@ -443,9 +464,22 @@
<ClCompile Include="..\..\src\initialaltitude\InitialAltitudeModule.cpp" />
<ClCompile Include="..\..\src\initialheading\InitialHeadingEventHandler.cpp" />
<ClCompile Include="..\..\src\initialheading\InitialHeadingModule.cpp" />
<ClCompile Include="..\..\src\integration\ClientInitialisationManager.cpp" />
<ClCompile Include="..\..\src\integration\DummyOutboundIntegrationMessageHandler.cpp" />
<ClCompile Include="..\..\src\integration\ExternalMessageEventHandler.cpp" />
<ClCompile Include="..\..\src\integration\HiddenWindow.cpp" />
<ClCompile Include="..\..\src\integration\InboundIntegrationMessageHandler.cpp" />
<ClCompile Include="..\..\src\integration\InboundMessage.cpp" />
<ClCompile Include="..\..\src\integration\InitialisationFailureMessage.cpp" />
<ClCompile Include="..\..\src\integration\InitialisationSuccessMessage.cpp" />
<ClCompile Include="..\..\src\integration\IntegrationClient.cpp" />
<ClCompile Include="..\..\src\integration\IntegrationClientManager.cpp" />
<ClCompile Include="..\..\src\integration\IntegrationConnection.cpp" />
<ClCompile Include="..\..\src\integration\IntegrationModule.cpp" />
<ClCompile Include="..\..\src\integration\IntegrationServer.cpp" />
<ClCompile Include="..\..\src\integration\OutboundIntegrationMessageHandler.cpp" />
<ClCompile Include="..\..\src\integration\SocketConnection.cpp" />
<ClCompile Include="..\..\src\integration\SocketWrapper.cpp" />
<ClCompile Include="..\..\src\intention\AirfieldGroup.cpp" />
<ClCompile Include="..\..\src\intention\AmsterdamAirfieldGroup.cpp" />
<ClCompile Include="..\..\src\intention\BrusselsAirfieldGroup.cpp" />
Expand All @@ -456,6 +490,7 @@
<ClCompile Include="..\..\src\intention\IntentionCodeFactory.cpp" />
<ClCompile Include="..\..\src\intention\IntentionCodeGenerator.cpp" />
<ClCompile Include="..\..\src\intention\IntentionCodeModule.cpp" />
<ClCompile Include="..\..\src\intention\IntentionCodeUpdatedMessage.cpp" />
<ClCompile Include="..\..\src\intention\SectorExitPoint.cpp" />
<ClCompile Include="..\..\src\intention\SectorExitPointEtrat.cpp" />
<ClCompile Include="..\..\src\intention\SectorExitPointKonan.cpp" />
Expand Down
Loading

0 comments on commit 739930e

Please sign in to comment.