Start of a redesign of SimClient (now renamed ClientView)/World/Avatar/Prim , switching to a event based system (World/Avatar register as event handlers). It is possible that I've broke something with this commit but it doesn't matter as I'll just hide and no one will find me.

zircon^2
MW 2007-05-21 16:06:58 +00:00
parent afab62dab3
commit fe46b045f7
23 changed files with 773 additions and 675 deletions

View File

@ -12,11 +12,11 @@ namespace OpenSim
public class AgentAssetUpload
{
private Dictionary<LLUUID, AssetTransaction> transactions = new Dictionary<LLUUID, AssetTransaction>();
private SimClient ourClient;
private ClientView ourClient;
private AssetCache m_assetCache;
private InventoryCache m_inventoryCache;
public AgentAssetUpload(SimClient client, AssetCache assetCache, InventoryCache inventoryCache)
public AgentAssetUpload(ClientView client, AssetCache assetCache, InventoryCache inventoryCache)
{
this.ourClient = client;
m_assetCache = assetCache;

View File

@ -324,7 +324,7 @@ namespace OpenSim.Assets
/// </summary>
/// <param name="userInfo"></param>
/// <param name="transferRequest"></param>
public void AddAssetRequest(SimClient userInfo, TransferRequestPacket transferRequest)
public void AddAssetRequest(ClientView userInfo, TransferRequestPacket transferRequest)
{
LLUUID requestID = new LLUUID(transferRequest.TransferInfo.Params, 0);
//check to see if asset is in local cache, if not we need to request it from asset server.
@ -464,7 +464,7 @@ namespace OpenSim.Assets
/// </summary>
/// <param name="userInfo"></param>
/// <param name="imageID"></param>
public void AddTextureRequest(SimClient userInfo, LLUUID imageID)
public void AddTextureRequest(ClientView userInfo, LLUUID imageID)
{
//check to see if texture is in local cache, if not request from asset server
if (!this.Textures.ContainsKey(imageID))
@ -517,7 +517,7 @@ namespace OpenSim.Assets
public class AssetRequest
{
public SimClient RequestUser;
public ClientView RequestUser;
public LLUUID RequestAssetID;
public AssetInfo AssetInf;
public TextureImage ImageInfo;

View File

@ -94,12 +94,12 @@ namespace OpenSim.Assets
}
}
public bool CreateNewInventoryFolder(SimClient remoteClient, LLUUID folderID)
public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID)
{
return this.CreateNewInventoryFolder(remoteClient, folderID, 0);
}
public bool CreateNewInventoryFolder(SimClient remoteClient, LLUUID folderID, ushort type)
public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type)
{
bool res = false;
if (folderID != LLUUID.Zero) //don't create a folder with a zero id
@ -112,7 +112,7 @@ namespace OpenSim.Assets
return res;
}
public bool CreateNewInventoryFolder(SimClient remoteClient, LLUUID folderID, ushort type, string folderName, LLUUID parent)
public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type, string folderName, LLUUID parent)
{
bool res = false;
if (folderID != LLUUID.Zero) //don't create a folder with a zero id
@ -125,7 +125,7 @@ namespace OpenSim.Assets
return res;
}
public LLUUID AddNewInventoryItem(SimClient remoteClient, LLUUID folderID, OpenSim.Framework.Types.AssetBase asset)
public LLUUID AddNewInventoryItem(ClientView remoteClient, LLUUID folderID, OpenSim.Framework.Types.AssetBase asset)
{
LLUUID newItem = null;
if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
@ -140,7 +140,7 @@ namespace OpenSim.Assets
return newItem;
}
public bool DeleteInventoryItem(SimClient remoteClient, LLUUID itemID)
public bool DeleteInventoryItem(ClientView remoteClient, LLUUID itemID)
{
bool res = false;
if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
@ -161,7 +161,7 @@ namespace OpenSim.Assets
return res;
}
public bool UpdateInventoryItemAsset(SimClient remoteClient, LLUUID itemID, OpenSim.Framework.Types.AssetBase asset)
public bool UpdateInventoryItemAsset(ClientView remoteClient, LLUUID itemID, OpenSim.Framework.Types.AssetBase asset)
{
if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
{
@ -177,7 +177,7 @@ namespace OpenSim.Assets
return false;
}
public bool UpdateInventoryItemDetails(SimClient remoteClient, LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
public bool UpdateInventoryItemDetails(ClientView remoteClient, LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
{
if (this._agentsInventory.ContainsKey(remoteClient.AgentID))
{
@ -193,7 +193,7 @@ namespace OpenSim.Assets
return false;
}
public void FetchInventoryDescendents(SimClient userInfo, FetchInventoryDescendentsPacket FetchDescend)
public void FetchInventoryDescendents(ClientView userInfo, FetchInventoryDescendentsPacket FetchDescend)
{
if (this._agentsInventory.ContainsKey(userInfo.AgentID))
{
@ -250,7 +250,7 @@ namespace OpenSim.Assets
}
}
public void FetchInventory(SimClient userInfo, FetchInventoryPacket FetchItems)
public void FetchInventory(ClientView userInfo, FetchInventoryPacket FetchItems)
{
if (this._agentsInventory.ContainsKey(userInfo.AgentID))
{
@ -291,7 +291,7 @@ namespace OpenSim.Assets
}
}
private void SendItemUpdateCreate(SimClient remoteClient, InventoryItem Item)
private void SendItemUpdateCreate(ClientView remoteClient, InventoryItem Item)
{
UpdateCreateInventoryItemPacket InventoryReply = new UpdateCreateInventoryItemPacket();

View File

@ -18,7 +18,7 @@ using OpenSim.Assets;
namespace OpenSim
{
public partial class SimClient
public partial class ClientView
{
public void EnableNeighbours()

View File

@ -18,7 +18,7 @@ using OpenSim.Assets;
namespace OpenSim
{
public partial class SimClient
public partial class ClientView
{
protected virtual void RegisterLocalPacketHandlers()
{
@ -27,7 +27,7 @@ namespace OpenSim
this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate);
}
protected virtual bool Logout(SimClient simClient, Packet packet)
protected virtual bool Logout(ClientView simClient, Packet packet)
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:ProcessInPacket() - Got a logout request");
//send reply to let the client logout
@ -43,7 +43,7 @@ namespace OpenSim
kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
kill.ObjectData[0].ID = this.ClientAvatar.localid;
foreach (SimClient client in m_clientThreads.Values)
foreach (ClientView client in m_clientThreads.Values)
{
client.OutPacket(kill);
}
@ -69,7 +69,7 @@ namespace OpenSim
return true;
}
protected bool AgentTextureCached(SimClient simclient, Packet packet)
protected bool AgentTextureCached(ClientView simclient, Packet packet)
{
// Console.WriteLine(packet.ToString());
AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet;
@ -90,7 +90,7 @@ namespace OpenSim
return true;
}
protected bool MultipleObjUpdate(SimClient simClient, Packet packet)
protected bool MultipleObjUpdate(ClientView simClient, Packet packet)
{
MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
for (int i = 0; i < multipleupdate.ObjectData.Length; i++)

View File

@ -18,9 +18,14 @@ using OpenSim.Assets;
namespace OpenSim
{
public partial class SimClient
public partial class ClientView
{
protected virtual void ProcessInPacket(Packet Pack)
public delegate void ChatFromViewer(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
public event ChatFromViewer OnChatFromViewer;
protected override void ProcessInPacket(Packet Pack)
{
ack_pack(Pack);
if (debug)
@ -42,6 +47,24 @@ namespace OpenSim
switch (Pack.Type)
{
#region New Event system
case PacketType.ChatFromViewer:
ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
if (Util.FieldToString(inchatpack.ChatData.Message) == "")
{
//empty message so don't bother with it
break;
}
string fromName = ClientAvatar.firstname + " " + ClientAvatar.lastname;
byte[] message = inchatpack.ChatData.Message;
byte type = inchatpack.ChatData.Type;
LLVector3 fromPos = ClientAvatar.Pos;
LLUUID fromAgentID = AgentID;
this.OnChatFromViewer(message, type, fromPos, fromName, fromAgentID);
break;
#endregion
#region World/Avatar/Primitive related packets
case PacketType.CompleteAgentMovement:
if (this.m_child) this.UpgradeClient();
ClientAvatar.CompleteMovement(m_world);
@ -53,13 +76,13 @@ namespace OpenSim
break;
case PacketType.AgentWearablesRequest:
ClientAvatar.SendInitialAppearance();
foreach (SimClient client in m_clientThreads.Values)
foreach (ClientView client in m_clientThreads.Values)
{
if (client.AgentID != this.AgentID)
{
ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket();
this.OutPacket(objupdate);
client.ClientAvatar.SendAppearanceToOtherAgent(this);
client.ClientAvatar.SendAppearanceToOtherAgent(this.ClientAvatar);
}
}
m_world.GetInitialPrims(this);
@ -120,18 +143,6 @@ namespace OpenSim
}
}
break;
case PacketType.RequestImage:
RequestImagePacket imageRequest = (RequestImagePacket)Pack;
for (int i = 0; i < imageRequest.RequestImage.Length; i++)
{
m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image);
}
break;
case PacketType.TransferRequest:
//Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request");
TransferRequestPacket transfer = (TransferRequestPacket)Pack;
m_assetCache.AddAssetRequest(this, transfer);
break;
case PacketType.AgentUpdate:
ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack);
break;
@ -158,6 +169,62 @@ namespace OpenSim
}
}
break;
case PacketType.AgentAnimation:
if (!m_child)
{
AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
for (int i = 0; i < AgentAni.AnimationList.Length; i++)
{
if (AgentAni.AnimationList[i].StartAnim)
{
ClientAvatar.current_anim = AgentAni.AnimationList[i].AnimID;
ClientAvatar.anim_seq = 1;
ClientAvatar.SendAnimPack();
}
}
}
break;
case PacketType.ObjectSelect:
ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
for (int i = 0; i < incomingselect.ObjectData.Length; i++)
{
foreach (Entity ent in m_world.Entities.Values)
{
if (ent.localid == incomingselect.ObjectData[i].ObjectLocalID)
{
((OpenSim.world.Primitive)ent).GetProperites(this);
break;
}
}
}
break;
case PacketType.ViewerEffect:
ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
foreach (ClientView client in m_clientThreads.Values)
{
if (client.AgentID != this.AgentID)
{
viewer.AgentData.AgentID = client.AgentID;
viewer.AgentData.SessionID = client.SessionID;
client.OutPacket(viewer);
}
}
break;
#endregion
#region Inventory/Asset/Other related packets
case PacketType.RequestImage:
RequestImagePacket imageRequest = (RequestImagePacket)Pack;
for (int i = 0; i < imageRequest.RequestImage.Length; i++)
{
m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image);
}
break;
case PacketType.TransferRequest:
//Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request");
TransferRequestPacket transfer = (TransferRequestPacket)Pack;
m_assetCache.AddAssetRequest(this, transfer);
break;
case PacketType.AssetUploadRequest:
AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID));
@ -228,18 +295,6 @@ namespace OpenSim
}
}
break;
case PacketType.ViewerEffect:
ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
foreach (SimClient client in m_clientThreads.Values)
{
if (client.AgentID != this.AgentID)
{
viewer.AgentData.AgentID = client.AgentID;
viewer.AgentData.SessionID = client.SessionID;
client.OutPacket(viewer);
}
}
break;
case PacketType.RequestTaskInventory:
// Console.WriteLine(Pack.ToString());
RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
@ -292,35 +347,6 @@ namespace OpenSim
}
}
break;
case PacketType.AgentAnimation:
if (!m_child)
{
AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
for (int i = 0; i < AgentAni.AnimationList.Length; i++)
{
if (AgentAni.AnimationList[i].StartAnim)
{
ClientAvatar.current_anim = AgentAni.AnimationList[i].AnimID;
ClientAvatar.anim_seq = 1;
ClientAvatar.SendAnimPack();
}
}
}
break;
case PacketType.ObjectSelect:
ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
for (int i = 0; i < incomingselect.ObjectData.Length; i++)
{
foreach (Entity ent in m_world.Entities.Values)
{
if (ent.localid == incomingselect.ObjectData[i].ObjectLocalID)
{
((OpenSim.world.Primitive)ent).GetProperites(this);
break;
}
}
}
break;
case PacketType.MapLayerRequest:
this.RequestMapLayer();
break;
@ -329,7 +355,6 @@ namespace OpenSim
this.RequestMapBlocks(MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY);
break;
case PacketType.TeleportLandmarkRequest:
TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
@ -378,7 +403,6 @@ namespace OpenSim
OutPacket(tpCancel);
}
break;
case PacketType.TeleportLocationRequest:
TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
Console.WriteLine(tpLocReq.ToString());
@ -410,8 +434,8 @@ namespace OpenSim
OutPacket(tpLocal);
}
break;
#endregion
}
}
}

View File

@ -44,43 +44,31 @@ using OpenSim.Assets;
namespace OpenSim
{
public delegate bool PacketMethod(SimClient simClient, Packet packet);
public delegate bool PacketMethod(ClientView simClient, Packet packet);
/// <summary>
/// Handles new client connections
/// Constructor takes a single Packet and authenticates everything
/// </summary>
public partial class SimClient
public partial class ClientView : ClientViewBase
{
public LLUUID AgentID;
public LLUUID SessionID;
public LLUUID SecureSessionID = LLUUID.Zero;
public bool m_child;
public uint CircuitCode;
public world.Avatar ClientAvatar;
private UseCircuitCodePacket cirpack;
public Thread ClientThread;
public EndPoint userEP;
public LLVector3 startpos;
private BlockingQueue<QueItem> PacketQueue;
private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>();
private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>();
//private Dictionary<LLUUID, AssetBase> UploadedAssets = new Dictionary<LLUUID, AssetBase>();
private System.Timers.Timer AckTimer;
private uint Sequence = 0;
private object SequenceLock = new object();
private const int MAX_APPENDED_ACKS = 10;
private const int RESEND_TIMEOUT = 4000;
private const int MAX_SEQUENCE = 0xFFFFFF;
private AgentAssetUpload UploadAssets;
private LLUUID newAssetFolder = LLUUID.Zero;
private bool debug = false;
private World m_world;
private Dictionary<uint, SimClient> m_clientThreads;
private Dictionary<uint, ClientView> m_clientThreads;
private AssetCache m_assetCache;
private IGridServer m_gridServer;
private IUserServer m_userServer = null;
private OpenSimNetworkHandler m_networkServer;
private InventoryCache m_inventoryCache;
public bool m_sandboxMode;
private int cachedtextureserial = 0;
@ -99,7 +87,7 @@ namespace OpenSim
}
}
public SimClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, World world, Dictionary<uint, SimClient> clientThreads, AssetCache assetCache, IGridServer gridServer, OpenSimNetworkHandler application, InventoryCache inventoryCache, bool sandboxMode, bool child, RegionInfo regionDat, AuthenticateSessionsBase authenSessions)
public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, World world, Dictionary<uint, ClientView> clientThreads, AssetCache assetCache, IGridServer gridServer, OpenSimNetworkHandler application, InventoryCache inventoryCache, bool sandboxMode, bool child, RegionInfo regionDat, AuthenticateSessionsBase authenSessions)
{
m_world = world;
m_clientThreads = clientThreads;
@ -170,7 +158,7 @@ namespace OpenSim
kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
kill.ObjectData[0].ID = this.ClientAvatar.localid;
foreach (SimClient client in m_clientThreads.Values)
foreach (ClientView client in m_clientThreads.Values)
{
client.OutPacket(kill);
}
@ -247,246 +235,6 @@ namespace OpenSim
# endregion
# region Low Level Packet Methods
private void ack_pack(Packet Pack)
{
if (Pack.Header.Reliable)
{
libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket();
ack_it.Packets = new PacketAckPacket.PacketsBlock[1];
ack_it.Packets[0] = new PacketAckPacket.PacketsBlock();
ack_it.Packets[0].ID = Pack.Header.Sequence;
ack_it.Header.Reliable = false;
OutPacket(ack_it);
}
/*
if (Pack.Header.Reliable)
{
lock (PendingAcks)
{
uint sequence = (uint)Pack.Header.Sequence;
if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; }
}
}*/
}
private void ResendUnacked()
{
int now = Environment.TickCount;
lock (NeedAck)
{
foreach (Packet packet in NeedAck.Values)
{
if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent))
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE, "Resending " + packet.Type.ToString() + " packet, " +
(now - packet.TickCount) + "ms have passed");
packet.Header.Resent = true;
OutPacket(packet);
}
}
}
}
private void SendAcks()
{
lock (PendingAcks)
{
if (PendingAcks.Count > 0)
{
if (PendingAcks.Count > 250)
{
// FIXME: Handle the odd case where we have too many pending ACKs queued up
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE, "Too many ACKs queued up!");
return;
}
//OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sending PacketAck");
int i = 0;
PacketAckPacket acks = new PacketAckPacket();
acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count];
foreach (uint ack in PendingAcks.Values)
{
acks.Packets[i] = new PacketAckPacket.PacketsBlock();
acks.Packets[i].ID = ack;
i++;
}
acks.Header.Reliable = false;
OutPacket(acks);
PendingAcks.Clear();
}
}
}
private void AckTimer_Elapsed(object sender, ElapsedEventArgs ea)
{
SendAcks();
ResendUnacked();
}
# endregion
#region Packet Queue Processing
protected virtual void ProcessOutPacket(Packet Pack)
{
// Keep track of when this packet was sent out
Pack.TickCount = Environment.TickCount;
if (!Pack.Header.Resent)
{
// Set the sequence number
lock (SequenceLock)
{
if (Sequence >= MAX_SEQUENCE)
Sequence = 1;
else
Sequence++;
Pack.Header.Sequence = Sequence;
}
if (Pack.Header.Reliable) //DIRTY HACK
{
lock (NeedAck)
{
if (!NeedAck.ContainsKey(Pack.Header.Sequence))
{
try
{
NeedAck.Add(Pack.Header.Sequence, Pack);
}
catch (Exception e) // HACKY
{
e.ToString();
// Ignore
// Seems to throw a exception here occasionally
// of 'duplicate key' despite being locked.
// !?!?!?
}
}
else
{
// Client.Log("Attempted to add a duplicate sequence number (" +
// packet.Header.Sequence + ") to the NeedAck dictionary for packet type " +
// packet.Type.ToString(), Helpers.LogLevel.Warning);
}
}
// Don't append ACKs to resent packets, in case that's what was causing the
// delivery to fail
if (!Pack.Header.Resent)
{
// Append any ACKs that need to be sent out to this packet
lock (PendingAcks)
{
if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS &&
Pack.Type != PacketType.PacketAck &&
Pack.Type != PacketType.LogoutRequest)
{
Pack.Header.AckList = new uint[PendingAcks.Count];
int i = 0;
foreach (uint ack in PendingAcks.Values)
{
Pack.Header.AckList[i] = ack;
i++;
}
PendingAcks.Clear();
Pack.Header.AppendedAcks = true;
}
}
}
}
}
byte[] ZeroOutBuffer = new byte[4096];
byte[] sendbuffer;
sendbuffer = Pack.ToBytes();
try
{
if (Pack.Header.Zerocoded)
{
int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP);
}
else
{
m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP);
}
}
catch (Exception)
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread");
ClientThread.Abort();
}
}
public virtual void InPacket(Packet NewPack)
{
// Handle appended ACKs
if (NewPack.Header.AppendedAcks)
{
lock (NeedAck)
{
foreach (uint ack in NewPack.Header.AckList)
{
NeedAck.Remove(ack);
}
}
}
// Handle PacketAck packets
if (NewPack.Type == PacketType.PacketAck)
{
PacketAckPacket ackPacket = (PacketAckPacket)NewPack;
lock (NeedAck)
{
foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets)
{
NeedAck.Remove(block.ID);
}
}
}
else if ((NewPack.Type == PacketType.StartPingCheck))
{
//reply to pingcheck
libsecondlife.Packets.StartPingCheckPacket startPing = (libsecondlife.Packets.StartPingCheckPacket)NewPack;
libsecondlife.Packets.CompletePingCheckPacket endPing = new CompletePingCheckPacket();
endPing.PingID.PingID = startPing.PingID.PingID;
OutPacket(endPing);
}
else
{
QueItem item = new QueItem();
item.Packet = NewPack;
item.Incoming = true;
this.PacketQueue.Enqueue(item);
}
}
public virtual void OutPacket(Packet NewPack)
{
QueItem item = new QueItem();
item.Packet = NewPack;
item.Incoming = false;
this.PacketQueue.Enqueue(item);
}
protected virtual void ClientLoop()
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:ClientLoop() - Entered loop");
@ -506,8 +254,6 @@ namespace OpenSim
}
}
#endregion
# region Setup
protected virtual void InitNewClient()
@ -556,6 +302,31 @@ namespace OpenSim
}
# endregion
protected override void KillThread()
{
this.ClientThread.Abort();
}
#region World/Avatar To Viewer Methods
public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
{
System.Text.Encoding enc = System.Text.Encoding.ASCII;
libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
reply.ChatData.Audible = 1;
reply.ChatData.Message = message;
reply.ChatData.ChatType = type;
reply.ChatData.SourceType = 1;
reply.ChatData.Position = fromPos;
reply.ChatData.FromName = enc.GetBytes(fromName + "\0");
reply.ChatData.OwnerID = fromAgentID;
reply.ChatData.SourceID = fromAgentID;
this.OutPacket(reply);
}
#endregion
#region Inventory Creation
private void SetupInventory(AuthenticateResponse sessionInfo)
{
@ -646,17 +417,5 @@ namespace OpenSim
}
#endregion
#region Nested Classes
public class QueItem
{
public QueItem()
{
}
public Packet Packet;
public bool Incoming;
}
#endregion
}
}

View File

@ -0,0 +1,299 @@
using System;
using System.Collections;
using System.Collections.Generic;
using libsecondlife;
using libsecondlife.Packets;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
using System.Timers;
using OpenSim.Framework.Utilities;
namespace OpenSim
{
public class ClientViewBase
{
protected BlockingQueue<QueItem> PacketQueue;
protected Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>();
protected Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>();
protected System.Timers.Timer AckTimer;
protected uint Sequence = 0;
protected object SequenceLock = new object();
protected const int MAX_APPENDED_ACKS = 10;
protected const int RESEND_TIMEOUT = 4000;
protected const int MAX_SEQUENCE = 0xFFFFFF;
public uint CircuitCode;
public EndPoint userEP;
protected OpenSimNetworkHandler m_networkServer;
public ClientViewBase()
{
}
protected virtual void ProcessInPacket(Packet Pack)
{
}
protected virtual void ProcessOutPacket(Packet Pack)
{
// Keep track of when this packet was sent out
Pack.TickCount = Environment.TickCount;
if (!Pack.Header.Resent)
{
// Set the sequence number
lock (SequenceLock)
{
if (Sequence >= MAX_SEQUENCE)
Sequence = 1;
else
Sequence++;
Pack.Header.Sequence = Sequence;
}
if (Pack.Header.Reliable) //DIRTY HACK
{
lock (NeedAck)
{
if (!NeedAck.ContainsKey(Pack.Header.Sequence))
{
try
{
NeedAck.Add(Pack.Header.Sequence, Pack);
}
catch (Exception e) // HACKY
{
e.ToString();
// Ignore
// Seems to throw a exception here occasionally
// of 'duplicate key' despite being locked.
// !?!?!?
}
}
else
{
// Client.Log("Attempted to add a duplicate sequence number (" +
// packet.Header.Sequence + ") to the NeedAck dictionary for packet type " +
// packet.Type.ToString(), Helpers.LogLevel.Warning);
}
}
// Don't append ACKs to resent packets, in case that's what was causing the
// delivery to fail
if (!Pack.Header.Resent)
{
// Append any ACKs that need to be sent out to this packet
lock (PendingAcks)
{
if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS &&
Pack.Type != PacketType.PacketAck &&
Pack.Type != PacketType.LogoutRequest)
{
Pack.Header.AckList = new uint[PendingAcks.Count];
int i = 0;
foreach (uint ack in PendingAcks.Values)
{
Pack.Header.AckList[i] = ack;
i++;
}
PendingAcks.Clear();
Pack.Header.AppendedAcks = true;
}
}
}
}
}
byte[] ZeroOutBuffer = new byte[4096];
byte[] sendbuffer;
sendbuffer = Pack.ToBytes();
try
{
if (Pack.Header.Zerocoded)
{
int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP);
}
else
{
m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP);
}
}
catch (Exception)
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread");
this.KillThread();
}
}
public virtual void InPacket(Packet NewPack)
{
// Handle appended ACKs
if (NewPack.Header.AppendedAcks)
{
lock (NeedAck)
{
foreach (uint ack in NewPack.Header.AckList)
{
NeedAck.Remove(ack);
}
}
}
// Handle PacketAck packets
if (NewPack.Type == PacketType.PacketAck)
{
PacketAckPacket ackPacket = (PacketAckPacket)NewPack;
lock (NeedAck)
{
foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets)
{
NeedAck.Remove(block.ID);
}
}
}
else if ((NewPack.Type == PacketType.StartPingCheck))
{
//reply to pingcheck
libsecondlife.Packets.StartPingCheckPacket startPing = (libsecondlife.Packets.StartPingCheckPacket)NewPack;
libsecondlife.Packets.CompletePingCheckPacket endPing = new CompletePingCheckPacket();
endPing.PingID.PingID = startPing.PingID.PingID;
OutPacket(endPing);
}
else
{
QueItem item = new QueItem();
item.Packet = NewPack;
item.Incoming = true;
this.PacketQueue.Enqueue(item);
}
}
public virtual void OutPacket(Packet NewPack)
{
QueItem item = new QueItem();
item.Packet = NewPack;
item.Incoming = false;
this.PacketQueue.Enqueue(item);
}
# region Low Level Packet Methods
protected void ack_pack(Packet Pack)
{
if (Pack.Header.Reliable)
{
libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket();
ack_it.Packets = new PacketAckPacket.PacketsBlock[1];
ack_it.Packets[0] = new PacketAckPacket.PacketsBlock();
ack_it.Packets[0].ID = Pack.Header.Sequence;
ack_it.Header.Reliable = false;
OutPacket(ack_it);
}
/*
if (Pack.Header.Reliable)
{
lock (PendingAcks)
{
uint sequence = (uint)Pack.Header.Sequence;
if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; }
}
}*/
}
protected void ResendUnacked()
{
int now = Environment.TickCount;
lock (NeedAck)
{
foreach (Packet packet in NeedAck.Values)
{
if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent))
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE, "Resending " + packet.Type.ToString() + " packet, " +
(now - packet.TickCount) + "ms have passed");
packet.Header.Resent = true;
OutPacket(packet);
}
}
}
}
protected void SendAcks()
{
lock (PendingAcks)
{
if (PendingAcks.Count > 0)
{
if (PendingAcks.Count > 250)
{
// FIXME: Handle the odd case where we have too many pending ACKs queued up
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE, "Too many ACKs queued up!");
return;
}
//OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sending PacketAck");
int i = 0;
PacketAckPacket acks = new PacketAckPacket();
acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count];
foreach (uint ack in PendingAcks.Values)
{
acks.Packets[i] = new PacketAckPacket.PacketsBlock();
acks.Packets[i].ID = ack;
i++;
}
acks.Header.Reliable = false;
OutPacket(acks);
PendingAcks.Clear();
}
}
}
protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea)
{
SendAcks();
ResendUnacked();
}
#endregion
protected virtual void KillThread()
{
}
#region Nested Classes
public class QueItem
{
public QueItem()
{
}
public Packet Packet;
public bool Incoming;
}
#endregion
}
}

View File

@ -136,6 +136,21 @@
<Compile Include="AuthenticateSessionsRemote.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ClientView.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ClientView.Grid.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ClientView.PacketHandlers.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ClientView.ProcessPackets.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ClientViewBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Grid.cs">
<SubType>Code</SubType>
</Compile>
@ -157,21 +172,6 @@
<Compile Include="RegionServerBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SimClient.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SimClient.Grid.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SimClient.PacketHandlers.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SimClient.ProcessPackets.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SimClientBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="UDPServer.cs">
<SubType>Code</SubType>
</Compile>

View File

@ -15,6 +15,11 @@
<include name="AuthenticateSessionsBase.cs" />
<include name="AuthenticateSessionsLocal.cs" />
<include name="AuthenticateSessionsRemote.cs" />
<include name="ClientView.cs" />
<include name="ClientView.Grid.cs" />
<include name="ClientView.PacketHandlers.cs" />
<include name="ClientView.ProcessPackets.cs" />
<include name="ClientViewBase.cs" />
<include name="Grid.cs" />
<include name="OpenSimMain.cs" />
<include name="OpenSimNetworkHandler.cs" />
@ -22,11 +27,6 @@
<include name="RegionInfo.cs" />
<include name="RegionInfoBase.cs" />
<include name="RegionServerBase.cs" />
<include name="SimClient.cs" />
<include name="SimClient.Grid.cs" />
<include name="SimClient.PacketHandlers.cs" />
<include name="SimClient.ProcessPackets.cs" />
<include name="SimClientBase.cs" />
<include name="UDPServer.cs" />
<include name="VersionInfo.cs" />
<include name="Assets/AssetCache.cs" />

View File

@ -10,7 +10,7 @@ namespace OpenSim
{
private OpenSimNetworkHandler _networkHandler;
private World _localWorld;
public Dictionary<uint, SimClient> ClientThreads = new Dictionary<uint, SimClient>();
public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>();
public PacketServer(OpenSimNetworkHandler networkHandler)
{
@ -44,7 +44,7 @@ namespace OpenSim
}
public virtual void SendPacketToAllExcept(Packet packet, SimClient simClient)
public virtual void SendPacketToAllExcept(Packet packet, ClientView simClient)
{
}
@ -58,17 +58,16 @@ namespace OpenSim
{
if (this._localWorld != null)
{
SimClient.AddPacketHandler(PacketType.ModifyLand, _localWorld.ModifyTerrain);
SimClient.AddPacketHandler(PacketType.ChatFromViewer, _localWorld.SimChat);
SimClient.AddPacketHandler(PacketType.RezObject, _localWorld.RezObject);
SimClient.AddPacketHandler(PacketType.DeRezObject, _localWorld.DeRezObject);
SimClient.AddPacketHandler(PacketType.UUIDNameRequest, this.RequestUUIDName);
ClientView.AddPacketHandler(PacketType.ModifyLand, _localWorld.ModifyTerrain);
ClientView.AddPacketHandler(PacketType.RezObject, _localWorld.RezObject);
ClientView.AddPacketHandler(PacketType.DeRezObject, _localWorld.DeRezObject);
ClientView.AddPacketHandler(PacketType.UUIDNameRequest, this.RequestUUIDName);
}
}
#region Client Packet Handlers
public bool RequestUUIDName(SimClient simClient, Packet packet)
public bool RequestUUIDName(ClientView simClient, Packet packet)
{
System.Text.Encoding enc = System.Text.Encoding.ASCII;
Console.WriteLine(packet.ToString());

View File

@ -1,32 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;
namespace OpenSim
{
public class SimClientBase
{
protected virtual void ProcessInPacket(Packet Pack)
{
}
protected virtual void ProcessOutPacket(Packet Pack)
{
}
public virtual void InPacket(Packet NewPack)
{
}
public virtual void OutPacket(Packet NewPack)
{
}
}
}

View File

@ -133,7 +133,7 @@ namespace OpenSim
this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code);
bool isChildAgent = false;
SimClient newuser = new SimClient(epSender, useCircuit, m_localWorld, _packetServer.ClientThreads, m_assetCache, m_gridServers.GridServer, this, m_inventoryCache, m_sandbox, isChildAgent, this.m_regionData, m_authenticateSessionsClass);
ClientView newuser = new ClientView(epSender, useCircuit, m_localWorld, _packetServer.ClientThreads, m_assetCache, m_gridServers.GridServer, this, m_inventoryCache, m_sandbox, isChildAgent, this.m_regionData, m_authenticateSessionsClass);
if ((this.m_gridServers.UserServer != null) && (user_accounts))
{
newuser.UserServer = this.m_gridServers.UserServer;

View File

@ -28,9 +28,10 @@ namespace OpenSim.world
terse.RegionData.TimeDilation = 64096;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
terse.ObjectData[0] = terseBlock;
foreach (SimClient client in m_clientThreads.Values)
List<Avatar> avList = this.m_world.RequestAvatarList();
foreach (Avatar client in avList)
{
client.OutPacket(terse);
client.SendPacketToViewer(terse);
}
updateflag = false;
@ -51,9 +52,10 @@ namespace OpenSim.world
terse.RegionData.TimeDilation = 64096;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
terse.ObjectData[0] = terseBlock;
foreach (SimClient client in m_clientThreads.Values)
List<Avatar> avList = this.m_world.RequestAvatarList();
foreach (Avatar client in avList)
{
client.OutPacket(terse);
client.SendPacketToViewer(terse);
}
_updateCount = 0;
}
@ -134,15 +136,13 @@ namespace OpenSim.world
byte[] pb = pos2.GetBytes();
Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
m_world._localNumber++;
foreach (SimClient client in m_clientThreads.Values)
{
client.OutPacket(objupdate);
if (client.AgentID != ControllingClient.AgentID)
{
//the below line is already in Simclient.cs at line number 245 , directly below the call to this method
//if there is a problem/bug with that , then lets fix it there rather than duplicating it here
//client.ClientAvatar.SendAppearanceToOtherAgent(this.ControllingClient);
List<Avatar> avList = this.m_world.RequestAvatarList();
foreach (Avatar client in avList)
{
client.SendPacketToViewer(objupdate);
if (client.ControllingClient.AgentID != this.ControllingClient.AgentID)
{
SendAppearanceToOtherAgent(client);
}
}
@ -169,30 +169,12 @@ namespace OpenSim.world
ControllingClient.OutPacket(aw);
}
public void SendAppearanceToOtherAgent(SimClient userInfo)
public void SendAppearanceToOtherAgent(Avatar avatarInfo)
{
AvatarAppearancePacket avp = new AvatarAppearancePacket();
avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
avp.ObjectData.TextureEntry = this.avatarAppearanceTexture.ToBytes();
//a wearable update packets should only be sent about the viewers/agents own avatar not for other avatars
//but it seems that the following code only created the packets and never actually sent them anyway
/*AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
aw.AgentData.AgentID = this.ControllingClient.AgentID;
aw.AgentData.SessionID = userInfo.SessionID;
aw.AgentData.SerialNum = 0; //removed the use of a random number as a random number could be less than the last number, should have a counter variable for this
aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
AgentWearablesUpdatePacket.WearableDataBlock awb;
for (int i = 0; i < 13; i++)
{
awb = new AgentWearablesUpdatePacket.WearableDataBlock();
awb.WearableType = (byte)i;
awb.AssetID = this.Wearables[i].AssetID;
awb.ItemID = this.Wearables[i].ItemID;
aw.WearableData[i] = awb;
}*/
AvatarAppearancePacket.VisualParamBlock avblock = null;
for (int i = 0; i < 218; i++)
{
@ -203,7 +185,7 @@ namespace OpenSim.world
avp.Sender.IsTrial = false;
avp.Sender.ID = ControllingClient.AgentID;
userInfo.OutPacket(avp);
avatarInfo.SendPacketToViewer(avp);
}
public void SetAppearance(AgentSetAppearancePacket appear)
@ -214,9 +196,11 @@ namespace OpenSim.world
{
this.visualParams[i] = appear.VisualParam[i].ParamValue;
}
foreach (SimClient client in m_clientThreads.Values)
List<Avatar> avList = this.m_world.RequestAvatarList();
foreach (Avatar client in avList)
{
if (client.AgentID != ControllingClient.AgentID)
if (client.ControllingClient.AgentID != this.ControllingClient.AgentID)
{
SendAppearanceToOtherAgent(client);
}
@ -320,11 +304,12 @@ namespace OpenSim.world
ani.AnimationList[0].AnimID = this.current_anim;
ani.AnimationList[0].AnimSequenceID = this.anim_seq;
//ControllingClient.OutPacket(ani);
foreach (SimClient client in m_clientThreads.Values)
List<Avatar> avList = this.m_world.RequestAvatarList();
foreach (Avatar client in avList)
{
client.OutPacket(ani);
client.SendPacketToViewer(ani);
}
}
}

View File

@ -16,7 +16,7 @@ namespace OpenSim.world
public static AvatarAnimations Animations;
public string firstname;
public string lastname;
public SimClient ControllingClient;
public ClientView ControllingClient;
public LLUUID current_anim;
public int anim_seq;
private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
@ -30,16 +30,16 @@ namespace OpenSim.world
private AvatarWearable[] Wearables;
private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
private ulong m_regionHandle;
private Dictionary<uint, SimClient> m_clientThreads;
//private Dictionary<uint, ClientView> m_clientThreads;
private string m_regionName;
private ushort m_regionWaterHeight;
private bool m_regionTerraform;
//private bool childShadowAvatar = false;
public Avatar(SimClient TheClient, World world, string regionName, Dictionary<uint, SimClient> clientThreads, ulong regionHandle, bool regionTerraform, ushort regionWater)
public Avatar(ClientView TheClient, World world, string regionName, Dictionary<uint, ClientView> clientThreads, ulong regionHandle, bool regionTerraform, ushort regionWater)
{
m_world = world;
m_clientThreads = clientThreads;
// m_clientThreads = clientThreads;
m_regionName = regionName;
m_regionHandle = regionHandle;
m_regionTerraform = regionTerraform;

View File

@ -22,7 +22,7 @@ namespace OpenSim.world
private bool physicsEnabled = false;
private bool physicstest = false;
private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
private Dictionary<uint, SimClient> m_clientThreads;
private Dictionary<uint, ClientView> m_clientThreads;
private ulong m_regionHandle;
private const uint FULL_MASK_PERMISSIONS = 2147483647;
@ -75,7 +75,7 @@ namespace OpenSim.world
}
}
public Primitive(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, World world)
public Primitive(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world)
{
mesh_cutbegin = 0.0f;
mesh_cutend = 1.0f;
@ -104,7 +104,7 @@ namespace OpenSim.world
return this.primData.ToBytes();
}
public void GetProperites(SimClient client)
public void GetProperites(ClientView client)
{
ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
@ -164,7 +164,7 @@ namespace OpenSim.world
}
if (this.newPrimFlag)
{
foreach (SimClient client in m_clientThreads.Values)
foreach (ClientView client in m_clientThreads.Values)
{
client.OutPacket(OurPacket);
}
@ -177,7 +177,7 @@ namespace OpenSim.world
terse.RegionData.TimeDilation = 64096;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
terse.ObjectData[0] = this.CreateImprovedBlock();
foreach (SimClient client in m_clientThreads.Values)
foreach (ClientView client in m_clientThreads.Values)
{
client.OutPacket(terse);
}
@ -185,7 +185,7 @@ namespace OpenSim.world
}
else if (this.dirtyFlag)
{
foreach (SimClient client in m_clientThreads.Values)
foreach (ClientView client in m_clientThreads.Values)
{
UpdateClient(client);
}
@ -202,7 +202,7 @@ namespace OpenSim.world
terse.RegionData.TimeDilation = 64096;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
terse.ObjectData[0] = this.CreateImprovedBlock();
foreach (SimClient client in m_clientThreads.Values)
foreach (ClientView client in m_clientThreads.Values)
{
client.OutPacket(terse);
}
@ -220,7 +220,7 @@ namespace OpenSim.world
}
}
public void UpdateClient(SimClient RemoteClient)
public void UpdateClient(ClientView RemoteClient)
{
LLVector3 lPos;

View File

@ -16,7 +16,7 @@ namespace OpenSim.world
protected PrimData primData;
//private ObjectUpdatePacket OurPacket;
private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
private Dictionary<uint, SimClient> m_clientThreads;
private Dictionary<uint, ClientView> m_clientThreads;
private ulong m_regionHandle;
private const uint FULL_MASK_PERMISSIONS = 2147483647;
private bool physicsEnabled = false;
@ -58,7 +58,7 @@ namespace OpenSim.world
}
#endregion
public Primitive2(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, World world)
public Primitive2(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world)
{
m_clientThreads = clientThreads;
m_regionHandle = regionHandle;
@ -66,6 +66,17 @@ namespace OpenSim.world
inventoryItems = new Dictionary<LLUUID, InventoryItem>();
}
public Primitive2(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world, LLUUID owner)
{
m_clientThreads = clientThreads;
m_regionHandle = regionHandle;
m_world = world;
inventoryItems = new Dictionary<LLUUID, InventoryItem>();
this.primData = new PrimData();
this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
this.primData.OwnerID = owner;
}
public byte[] GetByteArray()
{
byte[] result = null;
@ -159,7 +170,7 @@ namespace OpenSim.world
}
public void GetProperites(SimClient client)
public void GetProperites(ClientView client)
{
ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
@ -202,12 +213,12 @@ namespace OpenSim.world
return null;
}
public void RequestInventoryInfo(SimClient simClient, RequestTaskInventoryPacket packet)
public void RequestInventoryInfo(ClientView simClient, RequestTaskInventoryPacket packet)
{
}
public void RequestXferInventory(SimClient simClient, ulong xferID)
public void RequestXferInventory(ClientView simClient, ulong xferID)
{
//will only currently work if the total size of the inventory data array is under about 1000 bytes
SendXferPacketPacket send = new SendXferPacketPacket();
@ -246,7 +257,7 @@ namespace OpenSim.world
#region Update viewers Methods
//should change these mehtods, so that outgoing packets are sent through the avatar class
public void SendFullUpdateToClient(SimClient remoteClient)
public void SendFullUpdateToClient(ClientView remoteClient)
{
LLVector3 lPos;
if (this._physActor != null && this.physicsEnabled)
@ -273,7 +284,7 @@ namespace OpenSim.world
}
public void SendTerseUpdateToClient(SimClient RemoteClient)
public void SendTerseUpdateToClient(ClientView RemoteClient)
{
}

View File

@ -15,7 +15,7 @@ namespace OpenSim.world
{
private LLUUID rootUUID;
private Dictionary<LLUUID, Primitive2> ChildPrimitives = new Dictionary<LLUUID, Primitive2>();
private Dictionary<uint, SimClient> m_clientThreads;
private Dictionary<uint, ClientView> m_clientThreads;
private World m_world;
public SceneObject()
@ -42,7 +42,7 @@ namespace OpenSim.world
}
public void GetProperites(SimClient client)
public void GetProperites(ClientView client)
{
/*
ObjectPropertiesPacket proper = new ObjectPropertiesPacket();

View File

@ -16,7 +16,7 @@ namespace OpenSim.world
public partial class World
{
public bool ModifyTerrain(SimClient simClient, Packet packet)
public bool ModifyTerrain(ClientView simClient, Packet packet)
{
ModifyLandPacket modify = (ModifyLandPacket)packet;
@ -42,68 +42,44 @@ namespace OpenSim.world
return true;
}
public bool SimChat(SimClient simClient, Packet packet)
public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
{
System.Text.Encoding enc = System.Text.Encoding.ASCII;
ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)packet;
if (Util.FieldToString(inchatpack.ChatData.Message) == "")
{
//empty message so don't bother with it
return true;
}
string fromName = simClient.ClientAvatar.firstname + " " + simClient.ClientAvatar.lastname;
byte[] message = inchatpack.ChatData.Message;
byte type = inchatpack.ChatData.Type;
LLVector3 fromPos = simClient.ClientAvatar.Pos;
LLUUID fromAgentID = simClient.AgentID;
libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
reply.ChatData.Audible = 1;
reply.ChatData.Message = message;
reply.ChatData.ChatType = type;
reply.ChatData.SourceType = 1;
reply.ChatData.Position = fromPos;
reply.ChatData.FromName = enc.GetBytes(fromName + "\0");
reply.ChatData.OwnerID = fromAgentID;
reply.ChatData.SourceID = fromAgentID;
foreach (SimClient client in m_clientThreads.Values)
foreach (ClientView client in m_clientThreads.Values)
{
// int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
int dis = (int)client.ClientAvatar.Pos.GetDistanceTo(simClient.ClientAvatar.Pos);
int dis = (int)client.ClientAvatar.Pos.GetDistanceTo(fromPos);
switch (inchatpack.ChatData.Type)
switch (type)
{
case 0: // Whisper
if ((dis < 10) && (dis > -10))
{
client.OutPacket(reply);
//should change so the message is sent through the avatar rather than direct to the ClientView
client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
}
break;
case 1: // Say
if ((dis < 30) && (dis > -30))
{
client.OutPacket(reply);
client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
}
break;
case 2: // Shout
if ((dis < 100) && (dis > -100))
{
client.OutPacket(reply);
client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
}
break;
case 0xff: // Broadcast
client.OutPacket(reply);
client.SendChatMessage(message, type, fromPos, fromName, fromAgentID);
break;
}
}
return true;
}
public bool RezObject(SimClient simClient, Packet packet)
public bool RezObject(ClientView simClient, Packet packet)
{
RezObjectPacket rezPacket = (RezObjectPacket)packet;
AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID);
@ -126,7 +102,7 @@ namespace OpenSim.world
return true;
}
public bool DeRezObject(SimClient simClient, Packet packet)
public bool DeRezObject(ClientView simClient, Packet packet)
{
DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet;
@ -151,7 +127,7 @@ namespace OpenSim.world
kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
kill.ObjectData[0].ID = ent.localid;
foreach (SimClient client in m_clientThreads.Values)
foreach (ClientView client in m_clientThreads.Values)
{
client.OutPacket(kill);
}
@ -201,7 +177,7 @@ namespace OpenSim.world
kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
kill.ObjectData[0].ID = selectedEnt.localid;
foreach (SimClient client in m_clientThreads.Values)
foreach (ClientView client in m_clientThreads.Values)
{
client.OutPacket(kill);
}
@ -215,7 +191,7 @@ namespace OpenSim.world
return true;
}
public void RequestMapBlock(SimClient simClient, int minX, int minY, int maxX, int maxY)
public void RequestMapBlock(ClientView simClient, int minX, int minY, int maxX, int maxY)
{
System.Text.Encoding _enc = System.Text.Encoding.ASCII;
if (((m_regInfo.RegionLocX > minX) && (m_regInfo.RegionLocX < maxX)) && ((m_regInfo.RegionLocY > minY) && (m_regInfo.RegionLocY < maxY)))

View File

@ -57,7 +57,7 @@ namespace OpenSim.world
/// <param name="clientThreads">Dictionary to contain client threads</param>
/// <param name="regionHandle">Region Handle for this region</param>
/// <param name="regionName">Region Name for this region</param>
public World(Dictionary<uint, SimClient> clientThreads, RegionInfo regInfo, ulong regionHandle, string regionName)
public World(Dictionary<uint, ClientView> clientThreads, RegionInfo regInfo, ulong regionHandle, string regionName)
{
try
{
@ -324,7 +324,7 @@ namespace OpenSim.world
}
this.localStorage.SaveMap(this.Terrain.getHeights1D());
foreach (SimClient client in m_clientThreads.Values)
foreach (ClientView client in m_clientThreads.Values)
{
this.SendLayerData(client);
}
@ -355,7 +355,7 @@ namespace OpenSim.world
}
this.localStorage.SaveMap(this.Terrain.getHeights1D());
foreach (SimClient client in m_clientThreads.Values)
foreach (ClientView client in m_clientThreads.Values)
{
this.SendLayerData(client);
}
@ -389,7 +389,7 @@ namespace OpenSim.world
}
this.localStorage.SaveMap(this.Terrain.getHeights1D());
foreach (SimClient client in m_clientThreads.Values)
foreach (ClientView client in m_clientThreads.Values)
{
this.SendLayerData(pointx, pointy, client);
}
@ -437,7 +437,7 @@ namespace OpenSim.world
/// Sends prims to a client
/// </summary>
/// <param name="RemoteClient">Client to send to</param>
public void GetInitialPrims(SimClient RemoteClient)
public void GetInitialPrims(ClientView RemoteClient)
{
try
{
@ -495,7 +495,7 @@ namespace OpenSim.world
}
}
public void AddNewPrim(ObjectAddPacket addPacket, SimClient AgentClient)
public void AddNewPrim(ObjectAddPacket addPacket, ClientView AgentClient)
{
AddNewPrim(addPacket, AgentClient.AgentID);
}
@ -530,8 +530,9 @@ namespace OpenSim.world
#region Add/Remove Avatar Methods
public override void AddViewerAgent(SimClient agentClient)
public override void AddViewerAgent(ClientView agentClient)
{
agentClient.OnChatFromViewer += new ClientView.ChatFromViewer(this.SimChat);
try
{
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
@ -576,7 +577,7 @@ namespace OpenSim.world
}
}
public override void RemoveViewerAgent(SimClient agentClient)
public override void RemoveViewerAgent(ClientView agentClient)
{
try
{
@ -600,6 +601,23 @@ namespace OpenSim.world
}
#endregion
#region Request Avatars List Methods
//The idea is to have a group of method that return a list of avatars meeting some requirement
// ie it could be all Avatars within a certain range of the calling prim/avatar.
public List<Avatar> RequestAvatarList()
{
List<Avatar> result = new List<Avatar>();
foreach (Avatar avatar in Avatars.Values)
{
result.Add(avatar);
}
return result;
}
#endregion
#region ShutDown
/// <summary>
/// Tidy before shutdown

View File

@ -20,7 +20,7 @@ namespace OpenSim.world
public class WorldBase
{
public Dictionary<libsecondlife.LLUUID, Entity> Entities;
protected Dictionary<uint, SimClient> m_clientThreads;
protected Dictionary<uint, ClientView> m_clientThreads;
protected ulong m_regionHandle;
protected string m_regionName;
protected InventoryCache _inventoryCache;
@ -90,7 +90,7 @@ namespace OpenSim.world
/// Send the region heightmap to the client
/// </summary>
/// <param name="RemoteClient">Client to send to</param>
public virtual void SendLayerData(SimClient RemoteClient)
public virtual void SendLayerData(ClientView RemoteClient)
{
try
{
@ -122,7 +122,7 @@ namespace OpenSim.world
/// <param name="px">Patch coordinate (x) 0..16</param>
/// <param name="py">Patch coordinate (y) 0..16</param>
/// <param name="RemoteClient">The client to send to</param>
public void SendLayerData(int px, int py, SimClient RemoteClient)
public void SendLayerData(int px, int py, ClientView RemoteClient)
{
try
{
@ -148,7 +148,7 @@ namespace OpenSim.world
/// Add a new Agent's avatar
/// </summary>
/// <param name="agentClient"></param>
public virtual void AddViewerAgent(SimClient agentClient)
public virtual void AddViewerAgent(ClientView agentClient)
{
}
@ -157,7 +157,7 @@ namespace OpenSim.world
/// Remove a Agent's avatar
/// </summary>
/// <param name="agentClient"></param>
public virtual void RemoveViewerAgent(SimClient agentClient)
public virtual void RemoveViewerAgent(ClientView agentClient)
{
}

View File

@ -65,6 +65,72 @@ Global
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
({EE9E5D96-0000-0000-0000-000000000000}).6 = ({8ACA2445-0000-0000-0000-000000000000})
({EE9E5D96-0000-0000-0000-000000000000}).7 = ({A7CD0630-0000-0000-0000-000000000000})
({63A05FE9-0000-0000-0000-000000000000}).2 = ({8BE16150-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).5 = ({2270B8FE-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).6 = ({8ACA2445-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).7 = ({A7CD0630-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).8 = ({8BE16150-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).9 = ({8BB20F0A-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).10 = ({632E1BFD-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).11 = ({E88EF749-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).12 = ({8E81D43C-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).5 = ({2270B8FE-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).6 = ({8ACA2445-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).7 = ({A7CD0630-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).8 = ({E88EF749-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).9 = ({8BE16150-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).10 = ({8BB20F0A-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).11 = ({8E81D43C-0000-0000-0000-000000000000})
({8ACA2445-0000-0000-0000-000000000000}).4 = ({8E81D43C-0000-0000-0000-000000000000})
({8BE16150-0000-0000-0000-000000000000}).3 = ({8ACA2445-0000-0000-0000-000000000000})
({8BE16150-0000-0000-0000-000000000000}).4 = ({A7CD0630-0000-0000-0000-000000000000})
({97A82740-0000-0000-0000-000000000000}).2 = ({8ACA2445-0000-0000-0000-000000000000})
({0F3C3AC1-0000-0000-0000-000000000000}).3 = ({62CDF671-0000-0000-0000-000000000000})
({E88EF749-0000-0000-0000-000000000000}).2 = ({8ACA2445-0000-0000-0000-000000000000})
({66591469-0000-0000-0000-000000000000}).3 = ({8ACA2445-0000-0000-0000-000000000000})
({66591469-0000-0000-0000-000000000000}).4 = ({A7CD0630-0000-0000-0000-000000000000})
({66591469-0000-0000-0000-000000000000}).5 = ({62CDF671-0000-0000-0000-000000000000})
({66591469-0000-0000-0000-000000000000}).6 = ({8BB20F0A-0000-0000-0000-000000000000})
({66591469-0000-0000-0000-000000000000}).9 = ({8E81D43C-0000-0000-0000-000000000000})
({4F874463-0000-0000-0000-000000000000}).2 = ({8BE16150-0000-0000-0000-000000000000})
({8BB20F0A-0000-0000-0000-000000000000}).2 = ({8ACA2445-0000-0000-0000-000000000000})
({8BB20F0A-0000-0000-0000-000000000000}).3 = ({A7CD0630-0000-0000-0000-000000000000})
({8BB20F0A-0000-0000-0000-000000000000}).5 = ({8E81D43C-0000-0000-0000-000000000000})
({B0027747-0000-0000-0000-000000000000}).5 = ({8ACA2445-0000-0000-0000-000000000000})
({B0027747-0000-0000-0000-000000000000}).6 = ({A7CD0630-0000-0000-0000-000000000000})
({988F0AC4-0000-0000-0000-000000000000}).3 = ({8BE16150-0000-0000-0000-000000000000})
({0A563AC1-0000-0000-0000-000000000000}).3 = ({62CDF671-0000-0000-0000-000000000000})
({7924FD35-0000-0000-0000-000000000000}).1 = ({8ACA2445-0000-0000-0000-000000000000})
({7924FD35-0000-0000-0000-000000000000}).2 = ({8BB20F0A-0000-0000-0000-000000000000})
({7924FD35-0000-0000-0000-000000000000}).4 = ({8E81D43C-0000-0000-0000-000000000000})
({B55C0B5D-0000-0000-0000-000000000000}).3 = ({8ACA2445-0000-0000-0000-000000000000})
({B55C0B5D-0000-0000-0000-000000000000}).4 = ({A7CD0630-0000-0000-0000-000000000000})
({B55C0B5D-0000-0000-0000-000000000000}).5 = ({8E81D43C-0000-0000-0000-000000000000})
({21BFC8E2-0000-0000-0000-000000000000}).3 = ({8ACA2445-0000-0000-0000-000000000000})
({21BFC8E2-0000-0000-0000-000000000000}).4 = ({A7CD0630-0000-0000-0000-000000000000})
({21BFC8E2-0000-0000-0000-000000000000}).5 = ({8BB20F0A-0000-0000-0000-000000000000})
({21BFC8E2-0000-0000-0000-000000000000}).6 = ({62CDF671-0000-0000-0000-000000000000})
({21BFC8E2-0000-0000-0000-000000000000}).7 = ({7924FD35-0000-0000-0000-000000000000})
({21BFC8E2-0000-0000-0000-000000000000}).10 = ({8E81D43C-0000-0000-0000-000000000000})
({E1B79ECF-0000-0000-0000-000000000000}).4 = ({8ACA2445-0000-0000-0000-000000000000})
({E1B79ECF-0000-0000-0000-000000000000}).5 = ({A7CD0630-0000-0000-0000-000000000000})
({6B20B603-0000-0000-0000-000000000000}).5 = ({8ACA2445-0000-0000-0000-000000000000})
({6B20B603-0000-0000-0000-000000000000}).6 = ({A7CD0630-0000-0000-0000-000000000000})
({39BD9497-0000-0000-0000-000000000000}).3 = ({62CDF671-0000-0000-0000-000000000000})
({7E494328-0000-0000-0000-000000000000}).5 = ({8ACA2445-0000-0000-0000-000000000000})
({7E494328-0000-0000-0000-000000000000}).6 = ({A7CD0630-0000-0000-0000-000000000000})
({1E3F341A-0000-0000-0000-000000000000}).4 = ({62CDF671-0000-0000-0000-000000000000})
({546099CD-0000-0000-0000-000000000000}).4 = ({8ACA2445-0000-0000-0000-000000000000})
({546099CD-0000-0000-0000-000000000000}).5 = ({A7CD0630-0000-0000-0000-000000000000})
({0021261B-0000-0000-0000-000000000000}).3 = ({8ACA2445-0000-0000-0000-000000000000})
({0021261B-0000-0000-0000-000000000000}).4 = ({A7CD0630-0000-0000-0000-000000000000})
({0021261B-0000-0000-0000-000000000000}).5 = ({546099CD-0000-0000-0000-000000000000})
({0021261B-0000-0000-0000-000000000000}).6 = ({8BB20F0A-0000-0000-0000-000000000000})
({0021261B-0000-0000-0000-000000000000}).9 = ({8E81D43C-0000-0000-0000-000000000000})
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2270B8FE-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2270B8FE-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU

View File

@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
@ -6,8 +6,7 @@
<ProjectGuid>{E141F4EE-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon>
</ApplicationIcon>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>ServiceManager</AssemblyName>
@ -16,11 +15,9 @@
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Exe</OutputType>
<AppDesignerFolder>
</AppDesignerFolder>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>ServiceManager</RootNamespace>
<StartupObject>
</StartupObject>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
@ -31,8 +28,7 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
@ -41,8 +37,7 @@
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn>
</NoWarn>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
@ -51,8 +46,7 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
@ -61,19 +55,18 @@
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn>
</NoWarn>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.ServiceProcess">
<Reference Include="System.ServiceProcess" >
<HintPath>System.ServiceProcess.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml">
<Reference Include="System.Xml" >
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
@ -82,7 +75,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ServiceManager.cs">
<SubType>Component</SubType>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />