/// <summary>
		/// The process received data.
		/// </summary>
		/// <param name="pipe">
		/// The pipe.
		/// </param>
		protected override void processReceivedData(Pipe pipe)
		{
			try
			{
				this.Server.Codec.ParseBytePackage(pipe, this.TCPSocket.RemoteEndPoint);
			}
			catch (NullReferenceException exc)
			{
				while (this.Server == null)
				{
					Thread.Sleep(0);
				}

				this.Server.Codec.ParseBytePackage(pipe, this.TCPSocket.RemoteEndPoint);
			}
			catch (Exception e)
			{
			}
		}
Пример #2
0
		/// <summary>
		/// The process received data.
		/// </summary>
		/// <param name="dataPipe">
		/// The data pipe.
		/// </param>
		/// <param name="remoteEndPoint">
		/// The remote end point.
		/// </param>
		/// <param name="size">
		/// The size.
		/// </param>
		protected override void ProcessReceivedData(Pipe dataPipe, EndPoint remoteEndPoint, int size)
		{
			try
			{
				this.codec.ParseBytePackage(dataPipe, remoteEndPoint, size);
			}
			catch (NullReferenceException exc)
			{
				while (this.codec == null)
				{
					Thread.Sleep(0);
				}

				this.codec.ParseBytePackage(dataPipe, remoteEndPoint, size);
			}
			catch (Exception e)
			{
				Trace.Write("WGateWay Parsing Problem! (Reason: " + e + ")");
			}
		}
Пример #3
0
		/// <summary>
		/// The process received data.
		/// </summary>
		/// <param name="dataPipe">
		/// The data pipe.
		/// </param>
		protected abstract void processReceivedData(Pipe dataPipe);
Пример #4
0
		/// <summary>
		/// The parse byte package.
		/// </summary>
		/// <param name="dataPipe">
		/// The data pipe.
		/// </param>
		/// <param name="remoteEndPoint">
		/// The remote end point.
		/// </param>
		/// <param name="maxPacketSize">
		/// The max packet size.
		/// </param>
		internal void ParseBytePackage(Pipe dataPipe, EndPoint remoteEndPoint, int maxPacketSize)
		{
			var remoteAddress = remoteEndPoint.ToString();
			uint readedBytes = 0;
			ushort cmdId, dataType;
			uint payloadSize, dataCount, param1, param2;
			byte[] payload = null;
			byte[] header = null;

			while (maxPacketSize == 0 || maxPacketSize >= (readedBytes + 16))
			{
				header = dataPipe.Read(16);

				// Pipe destroyed
				if (header.Length == 0)
				{
					return;
				}

				cmdId = NetworkByteConverter.ToUInt16(header, 0);
				payloadSize = NetworkByteConverter.ToUInt16(header, 2);
				dataType = NetworkByteConverter.ToUInt16(header, 4);
				param1 = NetworkByteConverter.ToUInt32(header, 8);
				param2 = NetworkByteConverter.ToUInt32(header, 12);

				if (payloadSize == 0xFFFF)
				{
					payloadSize = NetworkByteConverter.ToUInt32(dataPipe.Read(4));
					dataCount = NetworkByteConverter.ToUInt32(dataPipe.Read(4));

					readedBytes += payloadSize + 24;
				}
				else
				{
					dataCount = NetworkByteConverter.ToUInt16(header, 6);
					readedBytes += payloadSize + 16;
				}

				payload = dataPipe.Read((int)payloadSize);

				this.HandleMessage(
					cmdId, 
					dataType, 
					ref payloadSize, 
					ref dataCount, 
					ref param1, 
					ref param2, 
					ref header, 
					ref payload, 
					ref remoteEndPoint);
			}
		}
Пример #5
0
		/// <summary>
		/// The parse byte package.
		/// </summary>
		/// <param name="dataPipe">
		/// The data pipe.
		/// </param>
		/// <param name="remoteEndPoint">
		/// The remote end point.
		/// </param>
		internal void ParseBytePackage(Pipe dataPipe, EndPoint remoteEndPoint)
		{
			this.ParseBytePackage(dataPipe, remoteEndPoint, 0);
		}
		/// <summary>
		/// The process received data.
		/// </summary>
		/// <param name="dataPipe">
		/// The data pipe.
		/// </param>
		/// <param name="remoteEndPoint">
		/// The remote end point.
		/// </param>
		/// <param name="size">
		/// The size.
		/// </param>
		protected override void ProcessReceivedData(Pipe dataPipe, EndPoint remoteEndPoint, int size)
		{
			try
			{
				this.Server.Codec.ParseBytePackage(dataPipe, remoteEndPoint, size);
			}
			catch (NullReferenceException exc)
			{
				while (this.Server == null)
				{
					Thread.Sleep(0);
				}

				this.Server.Codec.ParseBytePackage(dataPipe, remoteEndPoint, size);
			}
			catch (Exception e)
			{
				Trace.Write("WServer Parsing Error");
			}
		}
		/// <summary>
		/// The process received data.
		/// </summary>
		/// <param name="dataPipe">
		/// The data pipe.
		/// </param>
		/// <param name="remoteEndPoint">
		/// The remote end point.
		/// </param>
		/// <param name="size">
		/// The size.
		/// </param>
		protected override void ProcessReceivedData(Pipe dataPipe, EndPoint remoteEndPoint, int size)
		{
			try
			{
				this.Client.Codec.ParseBytePackage(dataPipe, remoteEndPoint, size);
			}
			catch (NullReferenceException exc)
			{
				while (this.Client == null)
				{
					Thread.Sleep(0);
				}

				this.Client.Codec.ParseBytePackage(dataPipe, remoteEndPoint, size);
			}
			catch (Exception e)
			{
				this.Client.ExceptionContainer.Add(e);
			}
		}
Пример #8
0
		/// <summary>
		/// The process received data.
		/// </summary>
		/// <param name="dataStream">
		/// The data stream.
		/// </param>
		/// <param name="remoteEndPoint">
		/// The remote end point.
		/// </param>
		/// <param name="Size">
		/// The size.
		/// </param>
		protected abstract void ProcessReceivedData(Pipe dataStream, EndPoint remoteEndPoint, int Size);
Пример #9
0
		/// <summary>
		/// The process received data.
		/// </summary>
		/// <param name="pipe">
		/// The pipe.
		/// </param>
		protected override void processReceivedData(Pipe pipe)
		{
			try
			{
				this.codec.ParseBytePackage(pipe, this.TCPSocket.RemoteEndPoint);
			}
			catch (NullReferenceException exc)
			{
				while (this.codec == null)
				{
					Thread.Sleep(0);
				}

				this.codec.ParseBytePackage(pipe, this.TCPSocket.RemoteEndPoint);
			}
			catch (Exception e)
			{
				Trace.Write("WFailure during parsing TCP Packet");
			}
		}