* Handlerized ViewerEffect
* Now there-is-only-client-manager * First step towards moving Logout and ConnectionClosed out of Client and into something else (which will let us get rid of ClientView reference to ClientManager * General posititvity, peace, love and understandingafrisby
parent
a963b3057b
commit
0bac4b430c
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using libsecondlife.Packets;
|
||||||
using OpenSim.Framework.Interfaces;
|
using OpenSim.Framework.Interfaces;
|
||||||
|
|
||||||
namespace OpenSim.Framework
|
namespace OpenSim.Framework
|
||||||
|
@ -32,5 +33,44 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
m_clients.Add(id, client);
|
m_clients.Add(id, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void InPacket(uint circuitCode, libsecondlife.Packets.Packet packet)
|
||||||
|
{
|
||||||
|
IClientAPI client;
|
||||||
|
|
||||||
|
if (m_clients.TryGetValue(circuitCode, out client))
|
||||||
|
{
|
||||||
|
client.InPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ConnectionClosed(uint circuitCode)
|
||||||
|
{
|
||||||
|
IClientAPI client;
|
||||||
|
|
||||||
|
if (m_clients.TryGetValue(circuitCode, out client))
|
||||||
|
{
|
||||||
|
m_clients.Remove(circuitCode);
|
||||||
|
client.Close();
|
||||||
|
|
||||||
|
// TODO: Now remove all local childagents too
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ViewerEffectHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock)
|
||||||
|
{
|
||||||
|
ViewerEffectPacket packet = new ViewerEffectPacket();
|
||||||
|
packet.Effect = effectBlock;
|
||||||
|
|
||||||
|
foreach (IClientAPI client in m_clients.Values)
|
||||||
|
{
|
||||||
|
if (client.AgentId != sender.AgentId)
|
||||||
|
{
|
||||||
|
packet.AgentData.AgentID = client.AgentId;
|
||||||
|
packet.AgentData.SessionID = client.SessionId;
|
||||||
|
client.OutPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ using OpenSim.Framework.Data;
|
||||||
|
|
||||||
namespace OpenSim.Framework.Interfaces
|
namespace OpenSim.Framework.Interfaces
|
||||||
{
|
{
|
||||||
|
public delegate void ViewerEffectEventHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock);
|
||||||
public delegate void ChatFromViewer(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
|
public delegate void ChatFromViewer(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
|
||||||
public delegate void ImprovedInstantMessage(LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID, uint timestamp, string fromAgentName, string message, byte dialog); // Cut down from full list
|
public delegate void ImprovedInstantMessage(LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID, uint timestamp, string fromAgentName, string message, byte dialog); // Cut down from full list
|
||||||
public delegate void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos);
|
public delegate void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos);
|
||||||
|
@ -242,6 +243,7 @@ namespace OpenSim.Framework.Interfaces
|
||||||
void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID);
|
void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID);
|
||||||
void SetDebug(int newDebug);
|
void SetDebug(int newDebug);
|
||||||
void InPacket(Packet NewPack);
|
void InPacket(Packet NewPack);
|
||||||
void ConnectionClosed();
|
void Close();
|
||||||
|
event ViewerEffectEventHandler OnViewerEffect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ namespace OpenSim.Framework
|
||||||
public event StatusChange OnChildAgentStatus;
|
public event StatusChange OnChildAgentStatus;
|
||||||
public event GenericCall2 OnStopMovement;
|
public event GenericCall2 OnStopMovement;
|
||||||
public event GenericCall6 OnRemoveAvatar;
|
public event GenericCall6 OnRemoveAvatar;
|
||||||
|
public event ViewerEffectEventHandler OnViewerEffect;
|
||||||
|
|
||||||
public event CreateNewInventoryItem OnCreateNewInventoryItem;
|
public event CreateNewInventoryItem OnCreateNewInventoryItem;
|
||||||
public event CreateInventoryFolder OnCreateNewInventoryFolder;
|
public event CreateInventoryFolder OnCreateNewInventoryFolder;
|
||||||
|
@ -172,9 +173,11 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConnectionClosed()
|
public void Close()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ namespace OpenSim.Region.ClientStack
|
||||||
{
|
{
|
||||||
partial class ClientView
|
partial class ClientView
|
||||||
{
|
{
|
||||||
|
public event ViewerEffectEventHandler OnViewerEffect;
|
||||||
public event ImprovedInstantMessage OnInstantMessage;
|
public event ImprovedInstantMessage OnInstantMessage;
|
||||||
public event ChatFromViewer OnChatFromViewer;
|
public event ChatFromViewer OnChatFromViewer;
|
||||||
public event RezObject OnRezObject;
|
public event RezObject OnRezObject;
|
||||||
|
|
|
@ -37,12 +37,27 @@ namespace OpenSim.Region.ClientStack
|
||||||
protected virtual void RegisterLocalPacketHandlers()
|
protected virtual void RegisterLocalPacketHandlers()
|
||||||
{
|
{
|
||||||
this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout);
|
this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout);
|
||||||
|
this.AddLocalPacketHandler(PacketType.ViewerEffect, this.HandleViewerEffect);
|
||||||
this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached);
|
this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached);
|
||||||
this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate);
|
this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual bool Logout(IClientAPI simClient, Packet packet)
|
private bool HandleViewerEffect(IClientAPI sender, Packet Pack)
|
||||||
{
|
{
|
||||||
|
ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
|
||||||
|
|
||||||
|
if( OnViewerEffect != null )
|
||||||
|
{
|
||||||
|
OnViewerEffect(sender, viewer.Effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual bool Logout(IClientAPI client, Packet packet)
|
||||||
|
{
|
||||||
|
// TODO: Refactor out this into an OnLogout so the ClientManager can close all clients.
|
||||||
|
|
||||||
MainLog.Instance.Verbose("OpenSimClient.cs:ProcessInPacket() - Got a logout request");
|
MainLog.Instance.Verbose("OpenSimClient.cs:ProcessInPacket() - Got a logout request");
|
||||||
//send reply to let the client logout
|
//send reply to let the client logout
|
||||||
LogoutReplyPacket logReply = new LogoutReplyPacket();
|
LogoutReplyPacket logReply = new LogoutReplyPacket();
|
||||||
|
@ -53,7 +68,8 @@ namespace OpenSim.Region.ClientStack
|
||||||
logReply.InventoryData[0].ItemID = LLUUID.Zero;
|
logReply.InventoryData[0].ItemID = LLUUID.Zero;
|
||||||
OutPacket(logReply);
|
OutPacket(logReply);
|
||||||
//
|
//
|
||||||
this.KillClient();
|
this.Close();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,19 +75,6 @@ namespace OpenSim.Region.ClientStack
|
||||||
|
|
||||||
switch (Pack.Type)
|
switch (Pack.Type)
|
||||||
{
|
{
|
||||||
case PacketType.ViewerEffect:
|
|
||||||
ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
|
|
||||||
foreach (IClientAPI client in m_clientThreads.Values)
|
|
||||||
{
|
|
||||||
if (client.AgentId != this.AgentId)
|
|
||||||
{
|
|
||||||
viewer.AgentData.AgentID = client.AgentId;
|
|
||||||
viewer.AgentData.SessionID = client.SessionId;
|
|
||||||
client.OutPacket(viewer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
#region Scene/Avatar
|
#region Scene/Avatar
|
||||||
case PacketType.AvatarPropertiesRequest:
|
case PacketType.AvatarPropertiesRequest:
|
||||||
AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
|
AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
|
||||||
|
|
|
@ -71,7 +71,7 @@ namespace OpenSim.Region.ClientStack
|
||||||
private LLUUID newAssetFolder = LLUUID.Zero;
|
private LLUUID newAssetFolder = LLUUID.Zero;
|
||||||
private int debug = 0;
|
private int debug = 0;
|
||||||
protected IScene m_scene;
|
protected IScene m_scene;
|
||||||
private Dictionary<uint, IClientAPI> m_clientThreads;
|
private ClientManager m_clientManager;
|
||||||
private AssetCache m_assetCache;
|
private AssetCache m_assetCache;
|
||||||
// private InventoryCache m_inventoryCache;
|
// private InventoryCache m_inventoryCache;
|
||||||
private int cachedtextureserial = 0;
|
private int cachedtextureserial = 0;
|
||||||
|
@ -83,12 +83,12 @@ namespace OpenSim.Region.ClientStack
|
||||||
private int probesWithNoIngressPackets = 0;
|
private int probesWithNoIngressPackets = 0;
|
||||||
private int lastPacketsReceived = 0;
|
private int lastPacketsReceived = 0;
|
||||||
|
|
||||||
public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, IClientAPI> clientThreads, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions)
|
public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions)
|
||||||
{
|
{
|
||||||
m_moneyBalance = 1000;
|
m_moneyBalance = 1000;
|
||||||
|
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
m_clientThreads = clientThreads;
|
m_clientManager = clientManager;
|
||||||
m_assetCache = assetCache;
|
m_assetCache = assetCache;
|
||||||
|
|
||||||
m_networkServer = packServer;
|
m_networkServer = packServer;
|
||||||
|
@ -127,24 +127,17 @@ namespace OpenSim.Region.ClientStack
|
||||||
|
|
||||||
# region Client Methods
|
# region Client Methods
|
||||||
|
|
||||||
public void KillClient()
|
public void Close()
|
||||||
{
|
{
|
||||||
clientPingTimer.Stop();
|
clientPingTimer.Stop();
|
||||||
|
|
||||||
m_scene.RemoveClient(this.AgentId);
|
m_scene.RemoveClient(this.AgentId);
|
||||||
|
|
||||||
m_clientThreads.Remove(this.CircuitCode);
|
m_clientManager.Remove(this.CircuitCode); // TODO: Move out and delete ref to clientmanager.
|
||||||
m_networkServer.RemoveClientCircuit(this.CircuitCode);
|
m_networkServer.RemoveClientCircuit(this.CircuitCode);
|
||||||
this.ClientThread.Abort();
|
this.ClientThread.Abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConnectionClosed()
|
|
||||||
{
|
|
||||||
clientPingTimer.Stop();
|
|
||||||
m_clientThreads.Remove(this.CircuitCode);
|
|
||||||
m_networkServer.RemoveClientCircuit(this.CircuitCode);
|
|
||||||
this.ClientThread.Abort();
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
# region Packet Handling
|
# region Packet Handling
|
||||||
|
@ -259,7 +252,8 @@ namespace OpenSim.Region.ClientStack
|
||||||
probesWithNoIngressPackets++;
|
probesWithNoIngressPackets++;
|
||||||
if (probesWithNoIngressPackets > 30)
|
if (probesWithNoIngressPackets > 30)
|
||||||
{
|
{
|
||||||
this.KillClient();
|
// Refactor out this into an OnConnectionClosed so the ClientManager can clean up
|
||||||
|
this.Close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,7 +40,6 @@ namespace OpenSim.Region.ClientStack
|
||||||
{
|
{
|
||||||
private ClientStackNetworkHandler _networkHandler;
|
private ClientStackNetworkHandler _networkHandler;
|
||||||
private IScene _localScene;
|
private IScene _localScene;
|
||||||
public Dictionary<uint, IClientAPI> ClientThreads = new Dictionary<uint, IClientAPI>();
|
|
||||||
private ClientManager m_clientManager = new ClientManager();
|
private ClientManager m_clientManager = new ClientManager();
|
||||||
public ClientManager ClientManager
|
public ClientManager ClientManager
|
||||||
{
|
{
|
||||||
|
@ -66,20 +65,14 @@ namespace OpenSim.Region.ClientStack
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="circuitCode"></param>
|
/// <param name="circuitCode"></param>
|
||||||
/// <param name="packet"></param>
|
/// <param name="packet"></param>
|
||||||
public virtual void ClientInPacket(uint circuitCode, Packet packet)
|
public virtual void InPacket(uint circuitCode, Packet packet)
|
||||||
{
|
{
|
||||||
if (this.ClientThreads.ContainsKey(circuitCode))
|
m_clientManager.InPacket(circuitCode, packet);
|
||||||
{
|
|
||||||
ClientThreads[circuitCode].InPacket(packet);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ConnectionClosed(uint circuitCode)
|
public virtual void ConnectionClosed(uint circuitCode)
|
||||||
{
|
{
|
||||||
if (this.ClientThreads.ContainsKey(circuitCode))
|
m_clientManager.ConnectionClosed(circuitCode);
|
||||||
{
|
|
||||||
ClientThreads[circuitCode].ConnectionClosed();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -129,9 +122,9 @@ namespace OpenSim.Region.ClientStack
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, IClientAPI> clientThreads, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions)
|
protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions)
|
||||||
{
|
{
|
||||||
return new ClientView(remoteEP, initialcirpack, clientThreads, scene, assetCache, packServer, authenSessions );
|
return new ClientView(remoteEP, initialcirpack, clientManager, scene, assetCache, packServer, authenSessions );
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -146,15 +139,18 @@ namespace OpenSim.Region.ClientStack
|
||||||
public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, AgentCircuitManager authenticateSessionsClass)
|
public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, AgentCircuitManager authenticateSessionsClass)
|
||||||
{
|
{
|
||||||
IClientAPI newuser =
|
IClientAPI newuser =
|
||||||
CreateNewClient(epSender, useCircuit, ClientThreads, _localScene, assetCache, this,
|
CreateNewClient(epSender, useCircuit, m_clientManager, _localScene, assetCache, this,
|
||||||
authenticateSessionsClass);
|
authenticateSessionsClass);
|
||||||
|
|
||||||
this.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser);
|
this.m_clientManager.Add(useCircuit.CircuitCode.Code, newuser);
|
||||||
this.m_clientManager.Add(useCircuit.CircuitCode.Code, (IClientAPI)newuser);
|
|
||||||
|
newuser.OnViewerEffect += m_clientManager.ViewerEffectHandler;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -126,7 +126,7 @@ namespace OpenSim.Region.ClientStack
|
||||||
if (this.clientCircuits.ContainsKey(epSender))
|
if (this.clientCircuits.ContainsKey(epSender))
|
||||||
{
|
{
|
||||||
//if so then send packet to the packetserver
|
//if so then send packet to the packetserver
|
||||||
this._packetServer.ClientInPacket(this.clientCircuits[epSender], packet);
|
this._packetServer.InPacket(this.clientCircuits[epSender], packet);
|
||||||
}
|
}
|
||||||
else if (packet.Type == PacketType.UseCircuitCode)
|
else if (packet.Type == PacketType.UseCircuitCode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,6 +43,7 @@ namespace SimpleApp
|
||||||
public event UpdateVector OnGrabObject;
|
public event UpdateVector OnGrabObject;
|
||||||
public event ObjectSelect OnDeGrabObject;
|
public event ObjectSelect OnDeGrabObject;
|
||||||
public event MoveObject OnGrabUpdate;
|
public event MoveObject OnGrabUpdate;
|
||||||
|
public event ViewerEffectEventHandler OnViewerEffect;
|
||||||
|
|
||||||
|
|
||||||
public event UpdateShape OnUpdatePrimShape;
|
public event UpdateShape OnUpdatePrimShape;
|
||||||
|
@ -228,7 +229,7 @@ namespace SimpleApp
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConnectionClosed()
|
public void Close()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue