Beispiel #1
0
			public void Push(byte[] data)
			{
				byte[] encode_buffer = new byte[YwEncrypt.MSG_MAX_STC_PACK_LEN];
				int encode_buffer_len = YwEncrypt.Encode(mParent.mPackNum, encode_buffer, data);
				
				ByteArray final_buffer = new ByteArray();
				
				// Fill content len.
				final_buffer.Put((ushort)encode_buffer_len);
				
				// Fill real content.
				final_buffer.Put(encode_buffer, encode_buffer_len);
				
				mParent.mPackNum++;

				mCacheData.Put(final_buffer.GetData());
				mCount++;
			}
Beispiel #2
0
			public void Send()
			{
				if (mCacheData.GetData().Length <= 0)
					return;
				
				// |--总长(2)--|--label(2)--|--num(1)--|--single len--|--single packet...--|
				ByteArray send = new ByteArray();
				byte[] data = mCacheData.GetData();
				send.Put((ushort)(data.Length+1));	// 总长
				send.Put((ushort)1);				// 多包
				send.Put((byte)mCount);				// 包的个数
				send.Put(data); 
				
				//mParent.mPackNum++;
			
				//mParent.PushRequest(send.GetData());
				mParent.Send(send.GetData());
				
				// 发送完后,清除数据
				mCacheData.Clear();
				mCount = 0;
			}
Beispiel #3
0
		public virtual byte[] WrapPacket(byte[] data)
		{		
			byte[] encode_buffer = new byte[YwEncrypt.MSG_MAX_STC_PACK_LEN];
			int encode_buffer_len = YwEncrypt.Encode(mPackNum, encode_buffer, data);
			
			ByteArray final_buffer = new ByteArray();
			
			// Fill head.
			final_buffer.Put((ushort)encode_buffer_len);
			final_buffer.Put((ushort)24);
			
			// Fill real content.
			final_buffer.Put(encode_buffer, encode_buffer_len);
			
			mPackNum++;
			
			return final_buffer.GetData();
		}