mirror of
https://github.com/DaKerboul/perun.git
synced 2026-08-09 18:05:40 +02:00
Updated perun.lua for 8.0.0
This commit is contained in:
@@ -9,9 +9,9 @@ package.cpath = package.cpath..";"..lfs.currentdir().."/LuaSocket/?.dll"
|
|||||||
|
|
||||||
Perun.RefreshStatus = 15 -- (int) base refresh rate in seconds to send status update (values lower than 60 may affect performance!)
|
Perun.RefreshStatus = 15 -- (int) base refresh rate in seconds to send status update (values lower than 60 may affect performance!)
|
||||||
Perun.RefreshMission = 60 -- (int) refresh rate in seconds to send mission information (values lower than 60 may affect performance!)
|
Perun.RefreshMission = 60 -- (int) refresh rate in seconds to send mission information (values lower than 60 may affect performance!)
|
||||||
Perun.UDPTargetPort = 48620 -- (int) UDP port to send data to
|
Perun.TCPTargetPort = 48620 -- (int) TCP port to send data to
|
||||||
Perun.UDPSourcePort = 48621 -- (int) UDP port to send data from
|
Perun.TCPPerunHost = "localhost" -- (string) IP adress of the Perun instance or "localhost"
|
||||||
Perun.Instance = 1 -- (int) Id number of instance (if multiple DCS instances are to run at the same PC)
|
Perun.Instance = 2 -- (int) Id number of instance (if multiple DCS instances are to run at the same PC)
|
||||||
Perun.JsonStatusLocation = "Scripts\\Json\\" -- (string) folder relative do user's SaveGames DCS folder -> status file updated each RefreshMission
|
Perun.JsonStatusLocation = "Scripts\\Json\\" -- (string) folder relative do user's SaveGames DCS folder -> status file updated each RefreshMission
|
||||||
Perun.MOTD_L1 = "Witamy na serwerze Gildia.org !" -- (string) Message send to players connecting the server - Line 1
|
Perun.MOTD_L1 = "Witamy na serwerze Gildia.org !" -- (string) Message send to players connecting the server - Line 1
|
||||||
Perun.MOTD_L2 = "Wymagamy obecnosci DCS SRS oraz TeamSpeak - szczegoly na forum" -- (string) Message send to players connecting the server - Line 2
|
Perun.MOTD_L2 = "Wymagamy obecnosci DCS SRS oraz TeamSpeak - szczegoly na forum" -- (string) Message send to players connecting the server - Line 2
|
||||||
@@ -20,7 +20,7 @@ Perun.MOTD_L2 = "Wymagamy obecnosci DCS SRS oraz TeamSpeak - szczegoly na forum"
|
|||||||
|
|
||||||
|
|
||||||
-- Variable init
|
-- Variable init
|
||||||
Perun.Version = "v0.6.0"
|
Perun.Version = "v0.8.0"
|
||||||
Perun.StatusData = {}
|
Perun.StatusData = {}
|
||||||
Perun.SlotsData = {}
|
Perun.SlotsData = {}
|
||||||
Perun.MissionData = {}
|
Perun.MissionData = {}
|
||||||
@@ -33,7 +33,7 @@ Perun.lastSentMission =0
|
|||||||
Perun.JsonStatusLocation = lfs.writedir() .. Perun.JsonStatusLocation
|
Perun.JsonStatusLocation = lfs.writedir() .. Perun.JsonStatusLocation
|
||||||
Perun.socket = require("socket")
|
Perun.socket = require("socket")
|
||||||
Perun.IsServer = true --DCS.isServer( ) -- TBD looks like DCS API error, always returning True
|
Perun.IsServer = true --DCS.isServer( ) -- TBD looks like DCS API error, always returning True
|
||||||
Perun.UDPSourcePort = Perun.UDPSourcePort + Perun.Instance - 1
|
Perun.TCPSourcePort = Perun.TCPTargetPort + 10 + Perun.Instance - 1
|
||||||
|
|
||||||
-- ########### Helper function definitions ###########
|
-- ########### Helper function definitions ###########
|
||||||
function stripChars(str)
|
function stripChars(str)
|
||||||
@@ -153,11 +153,34 @@ Perun.SideID2Name = function(id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- ########### Main code ###########
|
-- ########### Main code ###########
|
||||||
|
|
||||||
Perun.AddLog = function(text)
|
Perun.AddLog = function(text)
|
||||||
-- Adds logs to DCS.log file
|
-- Adds logs to DCS.log file
|
||||||
net.log("Perun : ".. text)
|
net.log("Perun : ".. text)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Perun.ConnectToPerun = function ()
|
||||||
|
Perun.AddLog("Connecting to TCP server")
|
||||||
|
Perun.TCP = assert(Perun.socket.tcp())
|
||||||
|
Perun.TCP:settimeout(2000)
|
||||||
|
_, err = Perun.TCP:connect(Perun.TCPPerunHost, Perun.TCPTargetPort)
|
||||||
|
if err then
|
||||||
|
Perun.AddLog("TCP connection error : " .. err)
|
||||||
|
else
|
||||||
|
Perun.AddLog("Connected to TCP server")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Perun.SendPacket = function (data_id,temp)
|
||||||
|
_, err = Perun.TCP:send(temp)
|
||||||
|
if err then
|
||||||
|
Perun.AddLog("Packed drop " .. data_id .. ", error: " .. err)
|
||||||
|
Perun.ConnectToPerun()
|
||||||
|
else
|
||||||
|
Perun.AddLog("Packet send " .. data_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Perun.UpdateJsonStatus = function()
|
Perun.UpdateJsonStatus = function()
|
||||||
-- Updates status json file
|
-- Updates status json file
|
||||||
TempData={}
|
TempData={}
|
||||||
@@ -184,8 +207,7 @@ Perun.Send = function(data_id, data_package)
|
|||||||
temp=net.lua2json(TempData)
|
temp=net.lua2json(TempData)
|
||||||
temp=stripChars(temp)
|
temp=stripChars(temp)
|
||||||
|
|
||||||
Perun.UDP:send(temp)
|
Perun.SendPacket(data_id,temp)
|
||||||
Perun.AddLog("Packet send "..data_id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Perun.UpdateStatusPart = function(part_id, data_package)
|
Perun.UpdateStatusPart = function(part_id, data_package)
|
||||||
@@ -259,6 +281,7 @@ end
|
|||||||
Perun.UpdateMission = function()
|
Perun.UpdateMission = function()
|
||||||
-- Main function for mission information updates
|
-- Main function for mission information updates
|
||||||
Perun.MissionData=DCS.getCurrentMission()
|
Perun.MissionData=DCS.getCurrentMission()
|
||||||
|
-- Perun.Send(4,Perun.MissionData)
|
||||||
end
|
end
|
||||||
|
|
||||||
Perun.LogChat = function(playerID,msg,all)
|
Perun.LogChat = function(playerID,msg,all)
|
||||||
@@ -655,11 +678,7 @@ end
|
|||||||
|
|
||||||
-- ########### Finalize and set callbacks ###########
|
-- ########### Finalize and set callbacks ###########
|
||||||
if Perun.IsServer then
|
if Perun.IsServer then
|
||||||
Perun.UDP = assert(Perun.socket.udp())
|
|
||||||
Perun.UDP:settimeout(0)
|
|
||||||
Perun.UDP:setsockname("*", Perun.UDPSourcePort)
|
|
||||||
Perun.UDP:setpeername("127.0.0.1",Perun.UDPTargetPort)
|
|
||||||
|
|
||||||
DCS.setUserCallbacks(Perun)
|
DCS.setUserCallbacks(Perun)
|
||||||
net.log("Loaded - Perun - VladMordock - " .. Perun.Version )
|
net.log("Perun by VladMordock was loaded: " .. Perun.Version )
|
||||||
|
Perun.ConnectToPerun()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -63,10 +63,11 @@ internal class TCPController
|
|||||||
Console.WriteLine("TCP: Waiting for packet");
|
Console.WriteLine("TCP: Waiting for packet");
|
||||||
TcpClient tcpClient = tcpServer.AcceptTcpClient(); //if a connection exists, the server will accept it
|
TcpClient tcpClient = tcpServer.AcceptTcpClient(); //if a connection exists, the server will accept it
|
||||||
NetworkStream ns = tcpClient.GetStream(); //networkstream is used to send/receive messages
|
NetworkStream ns = tcpClient.GetStream(); //networkstream is used to send/receive messages
|
||||||
|
//tcpClient.ReceiveBufferSize = 65534;
|
||||||
|
|
||||||
while (tcpClient.Connected && !TCPController.boolDone) //while the client is connected, we look for incoming messages
|
while (tcpClient.Connected && !TCPController.boolDone) //while the client is connected, we look for incoming messages
|
||||||
{
|
{
|
||||||
arrReceiveByteArray = new byte[1024]; //the messages arrive as byte array
|
arrReceiveByteArray = new byte[65534]; //the messages arrive as byte array
|
||||||
ns.Read(arrReceiveByteArray, 0, arrReceiveByteArray.Length); //the same networkstream reads the message sent by the client
|
ns.Read(arrReceiveByteArray, 0, arrReceiveByteArray.Length); //the same networkstream reads the message sent by the client
|
||||||
strReceivedData = Encoding.ASCII.GetString(arrReceiveByteArray, 0, arrReceiveByteArray.Length);
|
strReceivedData = Encoding.ASCII.GetString(arrReceiveByteArray, 0, arrReceiveByteArray.Length);
|
||||||
Console.WriteLine("Sender: {0} Payload: {1}", null, strReceivedData);
|
Console.WriteLine("Sender: {0} Payload: {1}", null, strReceivedData);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace Perun_v1
|
|||||||
public partial class form_Main : Form
|
public partial class form_Main : Form
|
||||||
{
|
{
|
||||||
// Variable definitions
|
// Variable definitions
|
||||||
public string[] arrSendBuffer = new string[100]; // Mysql send buffer
|
public string[] arrSendBuffer = new string[65534]; // Mysql send buffer
|
||||||
public bool boolLetMeOut = false; // Helper to handle system tray
|
public bool boolLetMeOut = false; // Helper to handle system tray
|
||||||
|
|
||||||
// ################################ Main ################################
|
// ################################ Main ################################
|
||||||
|
|||||||
Reference in New Issue
Block a user