|
|
|
@ -16,7 +16,7 @@ namespace PComm |
|
|
|
|
public class PClient |
|
|
|
|
{ |
|
|
|
|
private readonly int BUFF_SIZE = 1000 * 50; // 50kB |
|
|
|
|
private readonly int LARGE_DATA_SIZE_THRESHOLD = 1000000; // 1MB |
|
|
|
|
private readonly int LARGE_DATA_SIZE_THRESHOLD = 1000 * 50; // 50kB |
|
|
|
|
|
|
|
|
|
public delegate void ClientReceivedHandler(PClient sender, PDataType dataType, byte[] data); |
|
|
|
|
public event ClientReceivedHandler OnReceived; |
|
|
|
@ -103,8 +103,12 @@ namespace PComm |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private int SendData(byte[] data) |
|
|
|
|
private int SendByProtocol(PDataType dataType, byte[] data) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
byte[] type = BitConverter.GetBytes((int)dataType); |
|
|
|
|
SendToSocket(type); |
|
|
|
|
|
|
|
|
|
byte[] isCompressed; |
|
|
|
|
byte[] toSendData; |
|
|
|
|
// 데이터 크기 100B 이하 또는 50MB 이상 압축하지 않음 (CPU 부하시간 더 큼) |
|
|
|
@ -135,8 +139,7 @@ namespace PComm |
|
|
|
|
|
|
|
|
|
public int Send(PDataType dataType, byte[] data) |
|
|
|
|
{ |
|
|
|
|
socket.Send(BitConverter.GetBytes((int)dataType), SocketFlags.None); |
|
|
|
|
return SendData(data); |
|
|
|
|
return SendByProtocol(dataType, data); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void AcceptCallback(IAsyncResult ar) |
|
|
|
|