OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
TestLLUDPServer.cs
Go to the documentation of this file.
1 /*
2  * Copyright (c) Contributors, http://opensimulator.org/
3  * See CONTRIBUTORS.TXT for a full list of copyright holders.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of the OpenSimulator Project nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 using System;
29 using System.Collections.Generic;
30 using System.Net;
31 using System.Net.Sockets;
32 using Nini.Config;
33 using OpenMetaverse.Packets;
34 using OpenSim.Framework;
35 using OpenSim.Region.ClientStack.LindenUDP;
36 
37 namespace OpenSim.Tests.Common
38 {
43  {
44  public List<Packet> PacketsSent { get; private set; }
45 
46  public TestLLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager)
47  : base(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager)
48  {
49  PacketsSent = new List<Packet>();
50  }
51 
52  public override void SendAckImmediate(IPEndPoint remoteEndpoint, PacketAckPacket ack)
53  {
54  PacketsSent.Add(ack);
55  }
56 
57  public override void SendPacket(
58  LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method)
59  {
60  PacketsSent.Add(packet);
61  }
62 
63  public void ClientOutgoingPacketHandler(IClientAPI client, bool resendUnacked, bool sendAcks, bool sendPing)
64  {
65  m_resendUnacked = resendUnacked;
66  m_sendAcks = sendAcks;
67  m_sendPing = sendPing;
68 
69  ClientOutgoingPacketHandler(client);
70  }
71 
76 //
86 //
103 //
108 //
109 // /// <summary>
110 // /// Signal that this chunk should throw an exception on Socket.BeginReceive()
111 // /// </summary>
112 // /// <param name="epSender"></param>
113 // public void LoadReceiveWithBeginException(EndPoint epSender)
114 // {
115 // ChunkSenderTuple tuple = new ChunkSenderTuple(epSender);
116 // tuple.BeginReceiveException = true;
117 // m_chunksToLoad.Enqueue(tuple);
118 // }
119 //
120 // /// <summary>
121 // /// Load some data to be received by the LLUDPServer on the next receive call
122 // /// </summary>
123 // /// <param name="data"></param>
124 // /// <param name="epSender"></param>
125 // public void LoadReceive(byte[] data, EndPoint epSender)
126 // {
127 // m_chunksToLoad.Enqueue(new ChunkSenderTuple(data, epSender));
128 // }
129 //
130 // /// <summary>
131 // /// Load a packet to be received by the LLUDPServer on the next receive call
132 // /// </summary>
133 // /// <param name="packet"></param>
134 // public void LoadReceive(Packet packet, EndPoint epSender)
135 // {
136 // LoadReceive(packet.ToBytes(), epSender);
137 // }
138 //
139 // /// <summary>
140 // /// Calls the protected asynchronous result method. This fires out all data chunks currently queued for send
141 // /// </summary>
142 // /// <param name="result"></param>
143 // public void ReceiveData(IAsyncResult result)
144 // {
145 // // Doesn't work the same way anymore
148 // }
149  }
150 
154  public class ChunkSenderTuple
155  {
156  public byte[] Data;
157  public EndPoint Sender;
159 
160  public ChunkSenderTuple(byte[] data, EndPoint sender)
161  {
162  Data = data;
163  Sender = sender;
164  }
165 
166  public ChunkSenderTuple(EndPoint sender)
167  {
168  Sender = sender;
169  }
170  }
171 }
override void SendPacket(LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting, UnackedPacketMethod method)
Start the process of sending a packet to the client.
Tracks state for a client UDP connection and provides client-specific methods
Definition: LLUDPClient.cs:66
TestLLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager)
This class enables regression testing of the LLUDPServer by allowing us to intercept outgoing data...
The LLUDP server for a region. This handles incoming and outgoing packets for all UDP connections to ...
Definition: LLUDPServer.cs:252
ChunkSenderTuple(byte[] data, EndPoint sender)
void ClientOutgoingPacketHandler(IClientAPI client, bool resendUnacked, bool sendAcks, bool sendPing)
override void SendAckImmediate(IPEndPoint remoteEndpoint, PacketAckPacket ack)
delegate void UnackedPacketMethod(OutgoingPacket oPacket)
Record the data and sender tuple