Server Name

**GLOBALS**
- Read out server name from `Config/serverSettings.lua`
**SOCKET**
- Added `server_name` to transmitted UDP data
This commit is contained in:
Frank 2022-10-02 16:54:48 +02:00
parent 30aba1258d
commit c0f82eabb2
2 changed files with 17 additions and 1 deletions

View File

@ -44,3 +44,15 @@ end
if __na then if __na then
BASE:I("Check <DCS install folder>/Scripts/MissionScripting.lua and comment out the lines with sanitizeModule(''). Use at your own risk!)") BASE:I("Check <DCS install folder>/Scripts/MissionScripting.lua and comment out the lines with sanitizeModule(''). Use at your own risk!)")
end end
BASE.ServerName="Unknown"
if lfs and loadfile then
local serverfile=lfs.writedir() .. 'Config/serverSettings.lua'
if UTILS.FileExists(serverfile) then
loadfile(serverfile)()
if cfg and cfg.name then
BASE.ServerName=cfg.name
end
end
BASE.ServerName=BASE.ServerName or "Unknown"
BASE:I("Server Name: "..tostring(BASE.ServerName))
end

View File

@ -58,7 +58,7 @@ SOCKET.DataType={
--- SOCKET class version. --- SOCKET class version.
-- @field #string version -- @field #string version
SOCKET.version="0.1.0" SOCKET.version="0.2.0"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list
@ -121,6 +121,10 @@ end
-- @return #SOCKET self -- @return #SOCKET self
function SOCKET:SendTable(Table) function SOCKET:SendTable(Table)
-- Add server name for DCS
Table.server_name=BASE.ServerName or "Unknown"
-- Encode json table.
local json= self.json:encode(Table) local json= self.json:encode(Table)
-- Debug info. -- Debug info.