blob: 274a2d379dc8b180baea8a15ec20bd0dbbf8b415 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife.Packets;
using OpenSim.Framework.Interfaces;
namespace OpenSim.Framework
{
public delegate void ForEachClientDelegate(IClientAPI client);
public class ClientManager
{
private Dictionary<uint, IClientAPI> m_clients;
public void ForEachClient(ForEachClientDelegate whatToDo)
{
foreach (IClientAPI client in m_clients.Values)
{
whatToDo(client);
}
}
public ClientManager()
{
m_clients = new Dictionary<uint, IClientAPI>();
}
public void Remove(uint id)
{
m_clients.Remove(id);
}
public void Add(uint id, IClientAPI 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);
}
}
}
}
}
|