From cdb8f32efca17930655ab1a7fa27345b51342939 Mon Sep 17 00:00:00 2001 From: Dung Ta Van Date: Mon, 9 May 2022 22:30:18 +0700 Subject: [PATCH] update socket reader --- socket/EzySocketReader.cs | 9 ++------- socket/EzyUdpSocketReader.cs | 11 +++-------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/socket/EzySocketReader.cs b/socket/EzySocketReader.cs index 0bbcf9d..5efc391 100644 --- a/socket/EzySocketReader.cs +++ b/socket/EzySocketReader.cs @@ -13,23 +13,18 @@ namespace com.tvd12.ezyfoxserver.client.socket { public abstract class EzySocketReader : EzySocketAdapter { - protected EzyQueue dataQueue; protected EzySocketDataDecoder decoder; protected readonly int readBufferSize; + protected readonly EzyQueue dataQueue; protected readonly EzyCallback decodeBytesCallback; public EzySocketReader() { + this.dataQueue = new EzySynchronizedQueue(); this.readBufferSize = EzySocketConstants.MAX_READ_BUFFER_SIZE; this.decodeBytesCallback = message => onMesssageReceived(message); } - protected override void run() - { - this.dataQueue = new EzySynchronizedQueue(); - base.run(); - } - protected override void update() { byte[] readBytes = new byte[readBufferSize]; diff --git a/socket/EzyUdpSocketReader.cs b/socket/EzyUdpSocketReader.cs index fd000e1..74800e4 100644 --- a/socket/EzyUdpSocketReader.cs +++ b/socket/EzyUdpSocketReader.cs @@ -12,22 +12,17 @@ namespace com.tvd12.ezyfoxserver.client.socket { public class EzyUdpSocketReader : EzySocketAdapter { - protected readonly int readBufferSize; - protected EzyQueue dataQueue; protected EzySocketDataDecoder decoder; protected UdpClient datagramChannel; protected IPEndPoint serverEndPoint; + protected readonly int readBufferSize; + protected readonly EzyQueue dataQueue; public EzyUdpSocketReader() : base() - { - this.readBufferSize = EzySocketConstants.MAX_READ_BUFFER_SIZE; - } - - protected override void run() { this.dataQueue = new EzySynchronizedQueue(); this.serverEndPoint = new IPEndPoint(IPAddress.Any, 0); - base.run(); + this.readBufferSize = EzySocketConstants.MAX_READ_BUFFER_SIZE; } protected override void update()