This commit is contained in:
szporowolik
2019-09-13 12:28:40 +02:00
parent 36c713ba3f
commit 69501b4623
2 changed files with 25 additions and 6 deletions

View File

@@ -11,7 +11,7 @@ Perun.RefreshStatus = 15 -- (int) base refresh rate in seconds to se
Perun.RefreshMission = 60 -- (int) refresh rate in seconds to send mission information (values lower than 60 may affect performance!)
Perun.TCPTargetPort = 48620 -- (int) TCP port to send data to
Perun.TCPPerunHost = "localhost" -- (string) IP adress of the Perun instance or "localhost"
Perun.Instance = 2 -- (int) Id number of instance (if multiple DCS instances are to run at the same PC)
Perun.Instance = 1 -- (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.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
@@ -173,6 +173,7 @@ 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()

View File

@@ -67,9 +67,27 @@ internal class TCPController
while (tcpClient.Connected && !TCPController.boolDone) //while the client is connected, we look for incoming messages
{
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
strReceivedData = Encoding.ASCII.GetString(arrReceiveByteArray, 0, arrReceiveByteArray.Length);
//arrReceiveByteArray = new byte[tcpClient.ReceiveBufferSize]; //the messages arrive as byte array
//ns.Read(arrReceiveByteArray, 0, arrReceiveByteArray.Length); //the same networkstream reads the message sent by the client
//strReceivedData = Encoding.ASCII.GetString(arrReceiveByteArray, 0, arrReceiveByteArray.Length);
StringBuilder CompleteMessage = new StringBuilder();
if (ns.CanRead)
{
byte[] ReadBuffer = new byte[1024];
CompleteMessage = new StringBuilder();
int numberOfBytesRead = 0;
// Incoming message may be larger than the buffer size.
do
{
numberOfBytesRead = ns.Read(ReadBuffer, 0, ReadBuffer.Length);
CompleteMessage.AppendFormat("{0}", Encoding.ASCII.GetString(ReadBuffer, 0, numberOfBytesRead));
}
while (ns.DataAvailable);
}
strReceivedData = CompleteMessage.ToString();
Console.WriteLine("Sender: {0} Payload: {1}", null, strReceivedData);
dynamic dynamicRawTCPFrame = JsonConvert.DeserializeObject(strReceivedData); // Deserialize received frame