-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from flying-dice/develop
Develop
- Loading branch information
Showing
26 changed files
with
2,793 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This GitHub Actions workflow is designed to run the Cargo Release process | ||
# whenever there is a push to the 'main' branch or the workflow is manually triggered. | ||
|
||
name: Run Cargo Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # Trigger the workflow on push events to the 'main' branch | ||
workflow_dispatch: # Allow manual triggering of the workflow | ||
|
||
jobs: | ||
cargo_release: | ||
name: Run Cargo Release | ||
runs-on: windows-latest # Use the latest Windows runner | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 # Checkout the repository using the specified action | ||
|
||
- name: Set Up Rust | ||
uses: actions-rs/toolchain@v1 # Set up the Rust toolchain | ||
with: | ||
toolchain: stable # Use the stable Rust toolchain | ||
override: true # Override any existing toolchain configuration | ||
|
||
- name: Install Cargo Release | ||
run: cargo install cargo-release # Install the cargo-release tool | ||
|
||
- name: Run Cargo Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use the GitHub token for authentication | ||
run: cargo release --execute --no-publish # Run the cargo release command only creating a new tag but not publishing to crates.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# This GitHub Actions workflow is designed to create a GitHub Release | ||
# whenever a new tag is pushed to the repository or the workflow is manually triggered. | ||
|
||
name: Create GitHub Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' # Trigger the workflow on any tag that matches the pattern 'v*' | ||
workflow_dispatch: # Allow manual triggering of the workflow | ||
|
||
jobs: | ||
create_release: | ||
name: Create GitHub Release | ||
runs-on: windows-latest # Use the latest Windows runner | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 # Checkout the repository using the specified action | ||
|
||
- name: Set Up Rust | ||
uses: actions-rs/toolchain@v1 # Set up the Rust toolchain | ||
with: | ||
toolchain: stable # Use the stable Rust toolchain | ||
override: true # Override any existing toolchain configuration | ||
|
||
- name: Build DLL | ||
run: cargo build --release # Build the project in release mode | ||
|
||
- name: Create GitHub Release | ||
uses: ncipollo/release-action@v1 # Use the release action to create a GitHub Release | ||
with: | ||
artifacts: target/release/*.dll # Specify the artifacts to include in the release | ||
tag: ${{ github.ref_name }} # Use the tag created by `cargo release` | ||
name: Release ${{ github.ref_name }} # Set the release name to the tag name | ||
body: | | ||
This release was automatically created using cargo-release and GitHub Actions. # Set the release body | ||
token: ${{ secrets.GITHUB_TOKEN }} # Use the GitHub token for authentication |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/target | ||
.idea | ||
.idea | ||
logs |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
[package] | ||
name = "json-rpc-server" | ||
version = "0.1.0" | ||
name = "lua-json-rpc" | ||
version = "0.0.1" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
mlua = { version = "0.10", features = ["lua51", "module", "async", "serialize"] } | ||
tokio = "1.43.0" | ||
tokio = { version = "1.43.0", features = ["rt", "macros"] } | ||
actix-web = "4.9.0" | ||
actix-ws = "0.3.0" | ||
serde_json = "1.0.135" | ||
serde = { version = "1.0.217", features = ["derive"] } | ||
uuid = { version = "1.12.0", features = ["v4"] } | ||
log = "0.4.25" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[package.metadata.release] | ||
tag = true | ||
push = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@echo off | ||
|
||
:: Delete the target folder if it exists | ||
if exist target ( | ||
rmdir /s /q target | ||
echo Deleted the target folder. | ||
) else ( | ||
echo No target folder found, skipping deletion. | ||
) | ||
|
||
:: Set environment variables directly | ||
set LUA_LIB_NAME=lua | ||
set LUA_LIB=lua5.1/ | ||
set LUA_INC=lua5.1/include | ||
|
||
:: Run cargo build with the custom environment variables | ||
cargo build --release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
local usercallbacks = {} | ||
|
||
function usercallbacks.onSimulationFrame() | ||
net.dostring_in("mission", [[a_do_script("__loop()")]]) | ||
end | ||
|
||
function usercallbacks.onSimulationStop() | ||
log.info("[EXAMPLE] - Stopping JSON-RPC Server...") | ||
net.dostring_in("mission", [[a_do_script("__stop()")]]) | ||
end | ||
|
||
DCS.setUserCallbacks(usercallbacks) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package.path = package.path .. ";" .. lfs.writedir() .. "\\Scripts\\?.lua" | ||
package.cpath = package.cpath .. ";" .. lfs.writedir() .. "\\Scripts\\?.dll" | ||
|
||
local jsonrpc = require("lua_json_rpc") | ||
|
||
local port = 1359 | ||
|
||
env.info("[EXAMPLE] - Starting JSON-RPC server on port " .. port .. ", ARCH: " .. _ARCHITECTURE .. " VERION: " .. _VERSION) | ||
|
||
__stop = jsonrpc.start_server({ | ||
host = "0.0.0.0", | ||
port = port, | ||
workers = 2 | ||
}) | ||
|
||
function loop() | ||
jsonrpc.process_rpc(on_rpc) | ||
end | ||
|
||
function __loop() | ||
local success, err = pcall(loop) | ||
if not success then | ||
env.error("loop() error: " .. tostring(err), false) -- false to avoid a popup in DCS | ||
end | ||
end | ||
|
||
function on_rpc(payload) | ||
if (payload.id == nil) then | ||
return | ||
end | ||
|
||
local response = { | ||
id = payload.id, | ||
jsonrpc = "2.0", | ||
} | ||
|
||
if (string.match("subtract", payload.method)) then | ||
env.info("Subtracting " .. payload.params[1] .. " - " .. payload.params[2]) | ||
response.result = payload.params[1] - payload.params[2] | ||
end | ||
|
||
return response | ||
end |
Oops, something went wrong.