mirror of
https://github.com/DaKerboul/perun.git
synced 2026-08-09 17:05:39 +02:00
WIP
This commit is contained in:
@@ -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.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.TCPTargetPort = 48620 -- (int) TCP port to send data to
|
||||||
Perun.TCPPerunHost = "localhost" -- (string) IP adress of the Perun instance or "localhost"
|
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.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
|
||||||
@@ -172,7 +172,8 @@ Perun.ConnectToPerun = function ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
Perun.SendPacket = function (data_id,temp)
|
Perun.SendPacket = function (data_id,temp)
|
||||||
_, err = Perun.TCP:send(temp)
|
_, err = Perun.TCP:send(temp)
|
||||||
|
|
||||||
if err then
|
if err then
|
||||||
Perun.AddLog("Packed drop " .. data_id .. ", error: " .. err)
|
Perun.AddLog("Packed drop " .. data_id .. ", error: " .. err)
|
||||||
Perun.ConnectToPerun()
|
Perun.ConnectToPerun()
|
||||||
|
|||||||
@@ -64,12 +64,30 @@ internal class TCPController
|
|||||||
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;
|
//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[65534]; //the messages arrive as byte array
|
//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
|
//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);
|
||||||
|
|
||||||
|
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);
|
Console.WriteLine("Sender: {0} Payload: {1}", null, strReceivedData);
|
||||||
|
|
||||||
dynamic dynamicRawTCPFrame = JsonConvert.DeserializeObject(strReceivedData); // Deserialize received frame
|
dynamic dynamicRawTCPFrame = JsonConvert.DeserializeObject(strReceivedData); // Deserialize received frame
|
||||||
|
|||||||
Reference in New Issue
Block a user