mellowzippy
mellowzippy
CC#
Created by mellowzippy on 5/27/2024 in #help
✅ Readonly methods
$close
10 replies
CC#
Created by mellowzippy on 5/27/2024 in #help
✅ Readonly methods
oooo okay
10 replies
CC#
Created by mellowzippy on 5/27/2024 in #help
✅ Readonly methods
But it does right..? My methods modify my Entries property.
10 replies
CC#
Created by mellowzippy on 4/23/2024 in #help
✅ Mysterious byte problem
How do I close a ticket?
45 replies
CC#
Created by mellowzippy on 4/23/2024 in #help
✅ Mysterious byte problem
We encode it, then convert it to json, encode it again and send it
45 replies
CC#
Created by mellowzippy on 4/23/2024 in #help
✅ Mysterious byte problem
We figured it out, its because we encoded the chunk of hamlet text twice.
45 replies
CC#
Created by mellowzippy on 4/23/2024 in #help
✅ Mysterious byte problem
In theory, the content of each packet should be 1024 bytes (plus overhead, which should be the same). In practice, the total amount of bytes keeps changing everytime it gets sent.
45 replies
CC#
Created by mellowzippy on 4/23/2024 in #help
✅ Mysterious byte problem
Is okay
45 replies
CC#
Created by mellowzippy on 4/23/2024 in #help
✅ Mysterious byte problem
private Dictionary<int, (bool, byte[])>? InitializePackets()
{
Dictionary<int, (bool, byte[])>? packets = new();
try
{
string text = File.ReadAllText("hamlet.txt");
byte[] tempbuffer = Encoding.ASCII.GetBytes(text);
int amountOfPackets = (int)Math.Ceiling((double)tempbuffer.Length / (double)ChunkSize);

for (int i = 0; i < amountOfPackets; i++)
{
int startIndex = i * ChunkSize;
int length = Math.Min(ChunkSize, tempbuffer.Length - startIndex);
byte[] chunk = new byte[length];
Buffer.BlockCopy(tempbuffer, startIndex, chunk, 0, length);
packets[i] = (i == amountOfPackets - 1, chunk); // Mark last packet
}

return packets;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
HandleErrors(e);
}

return null!;
}
private Dictionary<int, (bool, byte[])>? InitializePackets()
{
Dictionary<int, (bool, byte[])>? packets = new();
try
{
string text = File.ReadAllText("hamlet.txt");
byte[] tempbuffer = Encoding.ASCII.GetBytes(text);
int amountOfPackets = (int)Math.Ceiling((double)tempbuffer.Length / (double)ChunkSize);

for (int i = 0; i < amountOfPackets; i++)
{
int startIndex = i * ChunkSize;
int length = Math.Min(ChunkSize, tempbuffer.Length - startIndex);
byte[] chunk = new byte[length];
Buffer.BlockCopy(tempbuffer, startIndex, chunk, 0, length);
packets[i] = (i == amountOfPackets - 1, chunk); // Mark last packet
}

return packets;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
HandleErrors(e);
}

return null!;
}
45 replies
CC#
Created by mellowzippy on 4/23/2024 in #help
✅ Mysterious byte problem
so hamlet (a big file) gets split into multiple packets of 1024 byes.
45 replies
CC#
Created by mellowzippy on 4/23/2024 in #help
✅ Mysterious byte problem
the length is always 1024
45 replies
CC#
Created by mellowzippy on 4/23/2024 in #help
✅ Mysterious byte problem
no
45 replies
CC#
Created by mellowzippy on 4/23/2024 in #help
✅ Mysterious byte problem
A string gets put into a byte[1024]
45 replies
CC#
Created by mellowzippy on 4/23/2024 in #help
✅ Mysterious byte problem
So why does it send a different amount of bytes
45 replies
CC#
Created by mellowzippy on 4/23/2024 in #help
✅ Mysterious byte problem
It would be the same amount of bytes, correct?
45 replies
CC#
Created by mellowzippy on 4/23/2024 in #help
✅ Mysterious byte problem
or
{"content": "abc"}
{"content": "def"}
{"content": "abc"}
{"content": "def"}
45 replies
CC#
Created by mellowzippy on 4/23/2024 in #help
✅ Mysterious byte problem
{"content": "abc"}
{"content": "cba"}
{"content": "abc"}
{"content": "cba"}
45 replies