mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-10-03 10:33:29 -04:00
Avoid messages from multiple threads rarely interleaving with each other
This commit is contained in:
parent
2115a8eccb
commit
d034a047b7
@ -95,12 +95,16 @@ namespace MCGalaxy.Network {
|
|||||||
|
|
||||||
public static byte[] Message(string message, CpeMessageType type, bool hasCp437) {
|
public static byte[] Message(string message, CpeMessageType type, bool hasCp437) {
|
||||||
byte[] buffer = new byte[66];
|
byte[] buffer = new byte[66];
|
||||||
buffer[0] = Opcode.Message;
|
WriteMessage(message, (byte)type, hasCp437, buffer, 0);
|
||||||
buffer[1] = (byte)type;
|
|
||||||
NetUtils.Write(message, buffer, 2, hasCp437);
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void WriteMessage(string message, byte type, bool hasCp437, byte[] buffer, int index) {
|
||||||
|
buffer[index++] = Opcode.Message;
|
||||||
|
buffer[index++] = type;
|
||||||
|
NetUtils.Write(message, buffer, index, hasCp437);
|
||||||
|
}
|
||||||
|
|
||||||
public static byte[] Kick(string message, bool cp437) {
|
public static byte[] Kick(string message, bool cp437) {
|
||||||
byte[] buffer = new byte[65];
|
byte[] buffer = new byte[65];
|
||||||
buffer[0] = Opcode.Kick;
|
buffer[0] = Opcode.Kick;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user