示例#1
0
		public override void SendAsync(
				List<byte[]> buffers, byte channelID = 0, PacketFlags flags = PacketFlags.Reliable)
		{
			int size = buffers.Select(b => b.Length).Sum();
			byte[] buffer = new byte[size];
			int index = 0;
			foreach (byte[] bytes in buffers)
			{
				Array.Copy(bytes, 0, buffer, index, bytes.Length);
				index += bytes.Length;
			}

			if (!this.isConnected)
			{
				BufferInfo info = new BufferInfo { Buffer = buffer, ChannelID = channelID, Flags = flags };
				this.queue.Enqueue(info);
				return;
			}

			this.socket.SendAsync(buffer, channelID, flags);
		}
示例#2
0
		public override void SendAsync(
				byte[] buffer, byte channelID = 0, PacketFlags flags = PacketFlags.Reliable)
		{
			if (!this.isConnected)
			{
				BufferInfo info = new BufferInfo { Buffer = buffer, ChannelID = channelID, Flags = flags };
				this.queue.Enqueue(info);
				return;
			}
			this.socket.SendAsync(buffer, channelID, flags);
		}