mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-10-03 02:21:53 -04:00
Fix it to not error so much
This commit is contained in:
parent
cb26d3c9e2
commit
c03528ff5d
@ -492,7 +492,9 @@ namespace MCGalaxy.Network {
|
||||
public void Disconnect() { Disconnect(1000); }
|
||||
public override void Close() { s.Close(); }
|
||||
}
|
||||
|
||||
#if SECURE_WEBSOCKETS
|
||||
// This code is unfinished and experimental, and is terrible quality. I apologise in advance.
|
||||
public sealed class SecureSocket : INetSocket, INetProtocol {
|
||||
readonly INetSocket raw;
|
||||
WrapperStream wrapper;
|
||||
@ -515,8 +517,16 @@ namespace MCGalaxy.Network {
|
||||
public override void Close() { raw.Close(); }
|
||||
public void Disconnect() { Close(); }
|
||||
|
||||
public override void Send(byte[] buffer, bool sync) { ssl.Write(buffer); }
|
||||
public override void SendLowPriority(byte[] buffer) { ssl.Write(buffer); }
|
||||
// This is an extremely UGLY HACK
|
||||
readonly object locker = new object();
|
||||
public override void Send(byte[] buffer, bool sync) {
|
||||
try {
|
||||
lock (locker) ssl.Write(buffer);
|
||||
} catch (Exception ex) {
|
||||
Logger.LogError("Error writing to secure stream", ex);
|
||||
}
|
||||
}
|
||||
public override void SendLowPriority(byte[] buffer) { Send(buffer, false); }
|
||||
|
||||
public int ProcessReceived(byte[] data, int count) {
|
||||
lock (wrapper.locker) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user