本文整理汇总了C#中LLClientView类的典型用法代码示例。如果您正苦于以下问题:C# LLClientView类的具体用法?C# LLClientView怎么用?C# LLClientView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LLClientView类属于命名空间,在下文中一共展示了LLClientView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendPackets
/// <summary>
/// Sends packets for this texture to a client until packetsToSend is
/// hit or the transfer completes
/// </summary>
/// <param name = "client">Reference to the client that the packets are destined for</param>
/// <param name = "packetsToSend">Maximum number of packets to send during this call</param>
/// <param name = "packetsSent">Number of packets sent during this call</param>
/// <returns>True if the transfer completes at the current discard level, otherwise false</returns>
public bool SendPackets(LLClientView client, int packetsToSend, out int packetsSent)
{
packetsSent = 0;
if (m_currentPacket <= m_stopPacket)
{
bool sendMore = true;
if (!m_sentInfo || (m_currentPacket == 0))
{
sendMore = !SendFirstPacket(client);
m_sentInfo = true;
++m_currentPacket;
++packetsSent;
}
if (m_currentPacket < 2)
{
m_currentPacket = 2;
}
while (sendMore && packetsSent < packetsToSend && m_currentPacket <= m_stopPacket)
{
sendMore = SendPacket(client);
++m_currentPacket;
++packetsSent;
}
}
return (m_currentPacket > m_stopPacket);
}
示例2: LLImageManager
//Constructor
public LLImageManager(LLClientView client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule)
{
m_imagestore = new Dictionary<UUID,J2KImage>();
m_priorities = new SortedList<double,UUID>();
m_priorityresolver = new Dictionary<int, int>();
m_client = client;
m_assetCache = pAssetCache;
if (pAssetCache != null)
m_missingsubstitute = pAssetCache.Get("5748decc-f629-461c-9a36-a35a221fe21f");
else
m_log.Error("[ClientView] - couldn't set missing image, all manner of things will probably break");
m_j2kDecodeModule = pJ2kDecodeModule;
}
示例3: SendPacket
private bool SendPacket(LLClientView client)
{
if (client == null || m_asset == null)
return false;
bool complete = false;
int imagePacketSize = ((int) m_currentPacket == (TexturePacketCount()))
? LastPacketSize()
: IMAGE_PACKET_SIZE;
try
{
if ((CurrentBytePosition() + IMAGE_PACKET_SIZE) > m_asset.Length)
{
imagePacketSize = LastPacketSize();
complete = true;
if ((CurrentBytePosition() + imagePacketSize) > m_asset.Length)
{
imagePacketSize = m_asset.Length - CurrentBytePosition();
complete = true;
}
}
// It's concievable that the client might request packet one
// from a one packet image, which is really packet 0,
// which would leave us with a negative imagePacketSize..
if (imagePacketSize > 0)
{
byte[] imageData = new byte[imagePacketSize];
int currentPosition = CurrentBytePosition();
try
{
Buffer.BlockCopy(m_asset, currentPosition, imageData, 0, imagePacketSize);
}
catch (Exception e)
{
MainConsole.Instance.ErrorFormat(
"[J2KIMAGE]: Texture block copy for the first packet failed. textureid={0}, assetlength={1}, currentposition={2}, imagepacketsize={3}, exception={4}",
TextureID, m_asset.Length, currentPosition, imagePacketSize, e.Message);
return false;
}
//Send the packet
client.SendImageNextPart((ushort) (m_currentPacket - 1), TextureID, imageData);
}
return !complete;
}
catch (Exception)
{
return false;
}
}
示例4: SendFirstPacket
private bool SendFirstPacket(LLClientView client)
{
if (client == null)
return false;
if (m_asset == null)
{
MainConsole.Instance.Warn("[J2KIMAGE]: Sending ImageNotInDatabase for texture " + TextureID);
client.SendImageNotFound(TextureID);
return true;
}
if (m_asset.Length <= FIRST_PACKET_SIZE)
{
// We have less then one packet's worth of data
client.SendImageFirstPart(1, TextureID, (uint) m_asset.Length, m_asset, 2);
m_stopPacket = 0;
return true;
}
// This is going to be a multi-packet texture download
byte[] firstImageData = new byte[FIRST_PACKET_SIZE];
try
{
Buffer.BlockCopy(m_asset, 0, firstImageData, 0, FIRST_PACKET_SIZE);
}
catch (Exception)
{
MainConsole.Instance.ErrorFormat(
"[J2KIMAGE]: Texture block copy for the first packet failed. textureid={0}, assetlength={1}",
TextureID, m_asset.Length);
return true;
}
client.SendImageFirstPart(TexturePacketCount(), TextureID, (uint) m_asset.Length, firstImageData,
(byte) ImageCodec.J2C);
return false;
}
示例5: AddClient
public virtual bool AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint,
AgentCircuitData sessionInfo)
{
MainConsole.Instance.Debug("[LLUDPServer] AddClient-" + circuitCode + "-" + agentID + "-" + sessionID + "-" +
remoteEndPoint +
"-" + sessionInfo);
IScenePresence SP;
if (!m_scene.TryGetScenePresence(agentID, out SP))
{
// Create the LLUDPClient
LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID,
remoteEndPoint, m_defaultRTO, m_maxRTO);
// Create the LLClientView
LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID,
sessionID, circuitCode);
client.OnLogout += LogoutHandler;
// Start the IClientAPI
m_scene.AddNewClient(client, null);
m_currentClients.Add(client);
}
else
{
MainConsole.Instance.DebugFormat(
"[LLUDPSERVER]: Ignoring a repeated UseCircuitCode ({0}) from {1} at {2} ",
circuitCode, agentID, remoteEndPoint);
}
return true;
}
示例6: AddClient
/// <summary>
/// Add a client.
/// </summary>
/// <param name="circuitCode"></param>
/// <param name="agentID"></param>
/// <param name="sessionID"></param>
/// <param name="remoteEndPoint"></param>
/// <param name="sessionInfo"></param>
/// <returns>The client if it was added. Null if the client already existed.</returns>
protected virtual IClientAPI AddClient(
uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo)
{
IClientAPI client = null;
// In priciple there shouldn't be more than one thread here, ever.
// But in case that happens, we need to synchronize this piece of code
// because it's too important
lock (this)
{
if (!m_scene.TryGetClient(agentID, out client))
{
LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO);
client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
client.OnLogout += LogoutHandler;
((LLClientView)client).DisableFacelights = m_disableFacelights;
client.Start();
}
}
return client;
}
示例7: SendPacket
private bool SendPacket(LLClientView client)
{
bool complete = false;
int imagePacketSize = ((int)m_packetNumber == (TexturePacketCount())) ? LastPacketSize() : cImagePacketSize;
try
{
if ((CurrentBytePosition() + cImagePacketSize) > m_asset.Data.Length)
{
imagePacketSize = LastPacketSize();
complete=true;
if ((CurrentBytePosition() + imagePacketSize) > m_asset.Data.Length)
{
imagePacketSize = m_asset.Data.Length - CurrentBytePosition();
complete = true;
}
}
// It's concievable that the client might request packet one
// from a one packet image, which is really packet 0,
// which would leave us with a negative imagePacketSize..
if (imagePacketSize > 0)
{
byte[] imageData = new byte[imagePacketSize];
try
{
Buffer.BlockCopy(m_asset.Data, CurrentBytePosition(), imageData, 0, imagePacketSize);
}
catch (Exception e)
{
m_log.Error("Error copying texture block. Out of memory? imagePacketSize was " + imagePacketSize.ToString() + " on packet " + m_packetNumber.ToString() + " out of " + m_stopPacket.ToString() + ". Exception: " + e.ToString());
return false;
}
//Send the packet
client.SendImageNextPart((ushort)(m_packetNumber-1), m_requestedUUID, imageData);
}
if (complete)
{
return false;
}
else
{
return true;
}
}
catch (Exception)
{
return false;
}
}
示例8: AddClient
/// <summary>
/// Add a client.
/// </summary>
/// <param name="circuitCode"></param>
/// <param name="agentID"></param>
/// <param name="sessionID"></param>
/// <param name="remoteEndPoint"></param>
/// <param name="sessionInfo"></param>
/// <returns>The client if it was added. Null if the client already existed.</returns>
protected virtual IClientAPI AddClient(
uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo)
{
IClientAPI client = null;
// We currently synchronize this code across the whole scene to avoid issues such as
// http://opensimulator.org/mantis/view.php?id=5365 However, once locking per agent circuit can be done
// consistently, this lock could probably be removed.
lock (this)
{
if (!m_scene.TryGetClient(agentID, out client))
{
LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO);
client = new LLClientView(m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
client.OnLogout += LogoutHandler;
client.DebugPacketLevel = DefaultClientPacketDebugLevel;
((LLClientView)client).DisableFacelights = m_disableFacelights;
client.Start();
}
}
return client;
}
示例9: AddClient
protected virtual bool AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AgentCircuitData sessionInfo)
{
IScenePresence SP;
if (!m_scene.TryGetScenePresence(agentID, out SP))
{
// Create the LLUDPClient
LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO);
// Create the LLClientView
LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
client.OnLogout += LogoutHandler;
client.DisableFacelights = m_disableFacelights;
// Start the IClientAPI
m_scene.AddNewClient(client);
m_currentClients.Add (client);
}
else
{
m_log.DebugFormat("[LLUDPSERVER]: Ignoring a repeated UseCircuitCode ({0}) from {1} at {2} ",
circuitCode, agentID, remoteEndPoint);
}
return true;
}
示例10: DeactivateClientDueToTimeout
/// <summary>
/// Deactivates the client if we don't receive any packets within a certain amount of time (default 60 seconds).
/// </summary>
/// <remarks>
/// If a connection is active then we will always receive packets even if nothing else is happening, due to
/// regular client pings.
/// </remarks>
/// <param name='client'></param>
private void DeactivateClientDueToTimeout(LLClientView client)
{
lock (client.CloseSyncLock)
{
m_log.WarnFormat(
"[LLUDPSERVER]: Ack timeout, disconnecting {0} agent for {1} in {2}",
client.SceneAgent.IsChildAgent ? "child" : "root", client.Name, m_scene.RegionInfo.RegionName);
StatsManager.SimExtraStats.AddAbnormalClientThreadTermination();
if (!client.SceneAgent.IsChildAgent)
client.Kick("Simulator logged you out due to connection timeout");
client.CloseWithoutChecks();
}
}
示例11: AddClient
protected virtual void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo)
{
// In priciple there shouldn't be more than one thread here, ever.
// But in case that happens, we need to synchronize this piece of code
// because it's too important
lock (this)
{
IClientAPI existingClient;
if (!m_scene.TryGetClient(agentID, out existingClient))
{
// Create the LLUDPClient
LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO);
// Create the LLClientView
LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
client.OnLogout += LogoutHandler;
client.DisableFacelights = m_disableFacelights;
// Start the IClientAPI
client.Start();
}
else
{
m_log.WarnFormat("[LLUDPSERVER]: Ignoring a repeated UseCircuitCode from {0} at {1} for circuit {2}",
existingClient.AgentId, remoteEndPoint, circuitCode);
}
}
}
示例12: IncomingPacket
/// <summary>
/// Constructor
/// </summary>
/// <param name="client">Reference to the client this packet came from</param>
/// <param name="packet">Packet data</param>
public IncomingPacket(LLClientView client, Packet packet)
{
Client = client;
Packet = packet;
}
示例13: AddNewClient
private bool AddNewClient(UseCircuitCodePacket useCircuitCode, IPEndPoint remoteEndPoint)
{
UUID agentID = useCircuitCode.CircuitCode.ID;
UUID sessionID = useCircuitCode.CircuitCode.SessionID;
uint circuitCode = useCircuitCode.CircuitCode.Code;
try
{
m_log.InfoFormat(
"[LLUDPSERVER]: UCC Received for client {0} circuit code {1}",
useCircuitCode.CircuitCode.ID, useCircuitCode.CircuitCode.Code);
LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO);
LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, agentID, sessionID, circuitCode);
m_scene.ConnectionManager.TryAttachUdpCircuit(client);
client.Start();
return true;
}
catch (OpenSim.Region.Framework.Connection.AttachUdpCircuitException e)
{
if (e.CircuitAlreadyExisted)
{
m_log.WarnFormat("[LLUDPSERVER]: Ignoring duplicate UDP connection request. {0}", e.Message);
//if the circuit matches, we can ACK the UCC since the client should be
//able to communicate with the current circuit
if (e.ExistingCircuitMatched)
{
return true;
}
else
{
return false;
}
}
else
{
m_log.ErrorFormat("[LLUDPSERVER]: Unable to start new connection: {0}", e);
return false;
}
}
}
示例14: AddClient
protected virtual bool AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo)
{
// Create the LLUDPClient
LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO);
IClientAPI existingClient;
//Check to make sure we arn't handling two or more circuit codes from the client if we are lagging badly.
// The block below this (TryGetClient) works as well, but if it gets locked up before the client is added to the scene, it will break
// So we do this check here as well.
lock (m_handlingCircuitCodes)
{
if (m_handlingCircuitCodes.Contains(agentID))
return false;
m_handlingCircuitCodes.Add(agentID);
}
if (!m_scene.TryGetClient(agentID, out existingClient))
{
// Create the LLClientView
LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
client.OnLogout += LogoutHandler;
client.DisableFacelights = m_disableFacelights;
// Start the IClientAPI
client.Start();
//Remove it from the check
m_handlingCircuitCodes.Remove(agentID);
return true;
}
else
{
m_log.WarnFormat("[LLUDPSERVER]: Ignoring a repeated UseCircuitCode from {0} at {1} for circuit {2}",
udpClient.AgentID, remoteEndPoint, circuitCode);
}
//Remove it from the check
m_handlingCircuitCodes.Remove(agentID);
return false;
}
示例15: SendPackets
public bool SendPackets(LLClientView client, int maxpack)
{
if (!m_completedSendAtCurrentDiscardLevel)
{
if (m_packetNumber <= m_stopPacket)
{
bool SendMore = true;
if (!m_sentinfo || (m_packetNumber == 0))
{
if (SendFirstPacket(client))
{
SendMore = false;
}
m_sentinfo = true;
m_packetNumber++;
}
// bool ignoreStop = false;
if (m_packetNumber < 2)
{
m_packetNumber = 2;
}
int count = 0;
while (SendMore && count < maxpack && m_packetNumber <= m_stopPacket)
{
count++;
SendMore = SendPacket(client);
m_packetNumber++;
}
if (m_packetNumber > m_stopPacket)
{
return true;
}
}
}
return false;
}