All Projects → DCS-gRPC → rust-server

DCS-gRPC / rust-server

Licence: AGPL-3.0 license
DCS gRPC server written in Rust. Get data out of DCS and send commands into DCS.

Programming Languages

rust
11053 projects
lua
6591 projects
Makefile
30231 projects

Projects that are alternatives of or similar to rust-server

django-grpc
Easy gRPC service based on Django application
Stars: ✭ 177 (+302.27%)
Mutual labels:  grpc-server
twitch2dcs
DCS World mod that allows twitch chat to be viewed inside the game
Stars: ✭ 24 (-45.45%)
Mutual labels:  dcs-world
protobuf-ts
Protobuf and RPC for TypeScript
Stars: ✭ 527 (+1097.73%)
Mutual labels:  grpc-server
shorty-rs
A simple URL shortener, written in Rust and gRPC
Stars: ✭ 14 (-68.18%)
Mutual labels:  grpc-rust
dcs-bios
DCS-BIOS Flightpanels Fork
Stars: ✭ 103 (+134.09%)
Mutual labels:  dcs-world
dcs-bios-arduino-library
A library designed to run on Arduinos and similar microcontrollers and communicate with DCS-BIOS.
Stars: ✭ 22 (-50%)
Mutual labels:  dcs-world
dcs-input-command-injector
DCS Mod to add custom input commands in your user profile instead of by modding the game for each aircraft. Prevents commands from being lost when DCS updates.
Stars: ✭ 35 (-20.45%)
Mutual labels:  dcs-world
OpenHornet
OpenHornet 1:1 F/A-18C Simulator Repository
Stars: ✭ 167 (+279.55%)
Mutual labels:  dcs-world
perun
Perun toolset for DCS World server admins. Reads simulation data and pushes it MySQL database.
Stars: ✭ 23 (-47.73%)
Mutual labels:  dcs-world
ControllerBuddy
Highly advanced game controller mapping
Stars: ✭ 47 (+6.82%)
Mutual labels:  dcs-world
streamdeck-dcs
Plugin for Stream Deck to send controls to DCS.
Stars: ✭ 19 (-56.82%)
Mutual labels:  dcs-world
Skynet-IADS
Adds IADS (integrated air defence) functionality to Digital Combat Simulator.
Stars: ✭ 131 (+197.73%)
Mutual labels:  dcs-world
Armeria
Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
Stars: ✭ 3,392 (+7609.09%)
Mutual labels:  grpc-server
griffin
gRPC server and client for Ruby
Stars: ✭ 79 (+79.55%)
Mutual labels:  grpc-server
upper
Upper is a open source back-end framework based on the Dart language.
Stars: ✭ 39 (-11.36%)
Mutual labels:  grpc-server
run-aspnet-grpc
Using gRPC in Microservices for Building a high-performance Interservice Communication with .Net 5. See gRPC Microservices and Step by Step Implementation on .NET Course w/ discount->
Stars: ✭ 82 (+86.36%)
Mutual labels:  grpc-server
ios-grpc-note-crud-app
Swift iOS gRPC Client Note Taking App
Stars: ✭ 16 (-63.64%)
Mutual labels:  grpc-server
grpcbox
Erlang grpc on chatterbox
Stars: ✭ 111 (+152.27%)
Mutual labels:  grpc-server

DCS gRPC Server

DCS gRPC is an RPC (Remote Procedure Call) server that allows network clients to interact with a currently running mission on a DCS server.

Installation

Download

Download the latest version of the server from the Releases and extract the zip file into your DCS Server directory.

This is typically found in C:\Users\USERNAME\Saved Games\DCS.openbeta_server. Once extracted you will have a Scripts\DCS-gRPC folder, a Mods\Tech\DCS-gRPC folder, and a Scripts\Hooks\DCS-gRPC.lua file in your server folder. As well as these scripts there will be a Docs/DCS-gRPC folder containing documentation and a Tools/DCS-gRPC folder containing client tools.

Prepare DCS

To make the gRPC server available in the mission scripting environment, add the following line to your MissionScripting.lua file that is found by default in the DCS World install folder at C:\Program Files\Eagle Dynamics\DCS World\Scripts\MissionScripting.lua. If you installed the server in another location then look for the Scripts\MissionScripting.lua file in there.

Note: The following file is in diff format to highlight the line that has been added. Do note include the + symbol when you paste into the MissionScripting.lua file.

  --Initialization script for the Mission lua Environment (SSE)

  dofile('Scripts/ScriptingSystem.lua')
+ dofile(lfs.writedir()..[[Scripts\DCS-gRPC\grpc-mission.lua]])

  --Sanitize Mission Scripting environment
  --This makes unavailable some unsecure functions.
  --Mission downloaded from server to client may contain potentialy harmful lua code that may use these functions.
  --You can remove the code below and make availble these functions at your own risk.

  local function sanitizeModule(name)
    _G[name] = nil
    package.loaded[name] = nil
  end

  do
    sanitizeModule('os')
    sanitizeModule('io')
    sanitizeModule('lfs')
    _G['require'] = nil
    _G['loadlib'] = nil
    _G['package'] = nil
  end

Running DCS-gRPC

There are two ways of running DCS-gRPC. One way allows it to run regardless of what mission is running and the other means that DCS-gRPC will only run if the mission scripting itself enables it.

Running regardless of mission

Create the file Saved Games\DCS\Config\dcs-grpc.lua and add the line below

autostart = true

As well as this you can set other options in this file. These are listed below:

-- Whether the `Eval` method is enabled or not.
evalEnabled = false

-- The host the gRPC listens on (use "0.0.0.0" to listen on all IP addresses of the host).
host = '127.0.0.1'

-- The port to listen on.
port = 50051

-- Whether debug logging is enabled or not.
debug = false

-- Limit of calls per second that are executed inside of the mission scripting environment.
throughputLimit = 600

Once you have done this start the DCS server and skip to the "Confirming that DCS-gRPC is running" section of this README.

Running only if the mission scripting enables it

Make sure that the file Saved Games\DCS\Config\dcs-grpc.lua does not exist (Delete if it does).

Add the following code to your mission. This will start the DCS-gRPC server. You can add this code to a DO SCRIPT trigger in your .miz file or you can add this code to an existing lua file that your mission may be running.

-- Load the gRPC server into the mission
GRPC.load()

As well as this you can set other options in the script before GRPC.Load() . These are listed below:

-- Whether the `Eval` method is enabled or not.
GRPC.evalEnabled = false

-- The host the gRPC listens on (use "0.0.0.0" to listen on all IP addresses of the host).
GRPC.host = '127.0.0.1'

-- The port to listen on.
GRPC.port = 50051

-- Whether debug logging is enabled or not.
GRPC.debug = false

-- Limit of calls per second that are executed inside of the mission scripting environment.
GRPC.throughputLimit = 600

For example:

GRPC.host = '0.0.0.0'
GRPC.load()

Confirming that DCS-gRPC is running

To confirm that the server is running check the \Logs\dcs.log file and look for entries prefixed with GRPC. You can also check for the present of a \Logs\grpc.log file.

The server will be running on port 50051 by default.

Client Development

DCS-gRPC, as the name implies, uses the gRPC framework to handle communication between clients and the server. gRPC supports a wide variety of languages which allows you to develop clients in the languages of your choice.

In order to develop clients for DCS-gRPC you must be familiar with gRPC concepts so we recommend reading the gRPC documentation for your language.

The gRPC .proto files are available in the Docs/DCS-gRPC folder and also available in the Github repo

Server Development

The following section is only applicable to people who want to developer the DCS-gRPC server itself.

Build Dependencies

  • Rust >=1.56
  • rustfmt (rustup component add rustfmt)

Build

make build

You may need to use the following in powershell

cargo build

Or if you want to use the hot reloading DLL (this is the same as make build):

cargo build --features hot-reload
copy target/debug/dcs_grpc.dll target/debug/dcs_grpc_hot_reload.dll

Prepare DCS

For development:

  • update your MissionScripting.lua to load grpc-mission.lua from your local clone, e.g.:
    - dofile(lfs.writedir()..[[Scripts\DCS-gRPC\grpc-mission.lua]])
    + dofile([[C:\Development\DCS-gRPC\rust-server\lua\DCS-gRPC\grpc-mission.lua]])
  • add custom dllPath and luaPath settings to your Saved Games\DCS\Config\dcs-grpc.lua:
    dllPath = [[C:\Development\DCS-gRPC\rust-server\target\debug\]]
    luaPath = [[C:\Development\DCS-gRPC\rust-server\lua\DCS-gRPC\]]
  • copy the hook script from lua\Hooks\DCS-gRPC.lua to Scripts\Hooks\DCS-gRPC.lua

Debugging

  • Search for [GRPC] in the DCS logs
  • Consult the gRPC Server logs at Saved Games\DCS.openbeta\Logs\gRPC.log

Test the running server via grpcurl: (Remove the .exe when running on Linux)

grpcurl.exe -plaintext -import-path ./protos -proto ./protos/dcs/dcs.proto -d '{\"text\": \"Works!\", \"display_time\": 10, \"clear_view\": false}' 127.0.0.1:50051 dcs.trigger.v0.TriggerService/OutText

or watch the mission event stream via:

grpcurl.exe -plaintext -import-path ./protos -proto ./protos/dcs/dcs.proto -d '{}' 127.0.0.1:50051 dcs.mission.v0.MissionService/StreamEvents

REPL

DCS-gRPC provides the facility to directly run lua code inside the mission scripting environment. This feature is mainly intended for development and is disabled by default. You can enable it via the GRPC settings (See Settings section above)

To build and run the repl run the following commands

cargo build --bin repl
# Make sure your DCS mission is running
cargo run --bin repl

Note that the REPL is hardcoded to connect to localhost on the default port

Once connected you can enter lua code to execute. Prefix the lua with return to have the lua code return a value to the client. For example:

return Group.getByName('Aerial-1')
= {
    "id_": 1
}

return Group.getByName('Aerial-1'):getName()
= Aerial-1

The REPL is also available in the release and can be run by running Tools/DCS-gRPC/repl.exe

Contributions

This repository is powered by GitHub Actions for the Continuous Integration (CI) services. The same CI checks would be triggered and executed as you push code to your forked repository, and providing early feedback before a maintainer executes a manual execution on the pull request.

Troublshooting

Linker Error 1104

If you see LINK : fatal error LNK1104: cannot open file when running cargo build make sure that there is no running DCS mission as that locks the DLL files. Exit the mission (You do not have to exit DCS) then re-run the command before restarting the mission.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].