mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-10-02 10:01:34 -04:00
Avoid messages from multiple threads rarely interleaving with each other
This commit is contained in:
parent
d034a047b7
commit
bcfbd1624d
@ -163,13 +163,16 @@ namespace MCGalaxy {
|
||||
if (cancelmessage) { cancelmessage = false; return; }
|
||||
|
||||
try {
|
||||
foreach (string raw in LineWrapper.Wordwrap(message)) {
|
||||
string line = raw;
|
||||
if (!Supports(CpeExt.EmoteFix) && LineEndsInEmote(line))
|
||||
line += '\'';
|
||||
List<string> lines = LineWrapper.Wordwrap(message);
|
||||
byte[] packet = new byte[lines.Count * 66];
|
||||
|
||||
Send(Packet.Message(line, (CpeMessageType)id, hasCP437));
|
||||
for (int i = 0; i < lines.Count; i++) {
|
||||
string line = lines[i];
|
||||
if (!Supports(CpeExt.EmoteFix) && LineEndsInEmote(line)) line += '\'';
|
||||
Packet.WriteMessage(line, id, hasCP437, packet, i * 66);
|
||||
}
|
||||
// So multi-line messages from multiple threads don't interleave
|
||||
Send(packet);
|
||||
} catch (Exception e) {
|
||||
Logger.LogError(e);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user