diff options
Diffstat (limited to 'OpenSim/Framework/General/ClientManager.cs')
-rw-r--r-- | OpenSim/Framework/General/ClientManager.cs | 135 |
1 files changed, 0 insertions, 135 deletions
diff --git a/OpenSim/Framework/General/ClientManager.cs b/OpenSim/Framework/General/ClientManager.cs deleted file mode 100644 index e34c051..0000000 --- a/OpenSim/Framework/General/ClientManager.cs +++ /dev/null | |||
@@ -1,135 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | using System.Collections.Generic; | ||
30 | using libsecondlife; | ||
31 | using libsecondlife.Packets; | ||
32 | |||
33 | namespace OpenSim.Framework | ||
34 | { | ||
35 | public delegate void ForEachClientDelegate(IClientAPI client); | ||
36 | |||
37 | public class ClientManager | ||
38 | { | ||
39 | private Dictionary<uint, IClientAPI> m_clients; | ||
40 | |||
41 | public void ForEachClient(ForEachClientDelegate whatToDo) | ||
42 | { | ||
43 | foreach (IClientAPI client in m_clients.Values) | ||
44 | { | ||
45 | whatToDo(client); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | public ClientManager() | ||
50 | { | ||
51 | m_clients = new Dictionary<uint, IClientAPI>(); | ||
52 | } | ||
53 | |||
54 | private void Remove(uint id) | ||
55 | { | ||
56 | m_clients.Remove(id); | ||
57 | } | ||
58 | |||
59 | public void Add(uint id, IClientAPI client) | ||
60 | { | ||
61 | m_clients.Add(id, client); | ||
62 | } | ||
63 | |||
64 | public void InPacket(uint circuitCode, Packet packet) | ||
65 | { | ||
66 | IClientAPI client; | ||
67 | |||
68 | if (m_clients.TryGetValue(circuitCode, out client)) | ||
69 | { | ||
70 | client.InPacket(packet); | ||
71 | } | ||
72 | } | ||
73 | |||
74 | public void CloseAllAgents(uint circuitCode) | ||
75 | { | ||
76 | IClientAPI client; | ||
77 | |||
78 | if (m_clients.TryGetValue(circuitCode, out client)) | ||
79 | { | ||
80 | CloseAllCircuits(client.AgentId); | ||
81 | } | ||
82 | } | ||
83 | |||
84 | public void CloseAllCircuits(LLUUID agentId) | ||
85 | { | ||
86 | uint[] circuits = GetAllCircuits(agentId); | ||
87 | foreach (uint circuit in circuits) | ||
88 | { | ||
89 | IClientAPI client; | ||
90 | if (m_clients.TryGetValue(circuit, out client)) | ||
91 | { | ||
92 | Remove(circuit); | ||
93 | client.Close(); | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | |||
98 | private uint[] GetAllCircuits(LLUUID agentId) | ||
99 | { | ||
100 | List<uint> circuits = new List<uint>(); | ||
101 | |||
102 | foreach (KeyValuePair<uint, IClientAPI> pair in m_clients) | ||
103 | { | ||
104 | if (pair.Value.AgentId == agentId) | ||
105 | { | ||
106 | circuits.Add(pair.Key); | ||
107 | } | ||
108 | } | ||
109 | |||
110 | return circuits.ToArray(); | ||
111 | } | ||
112 | |||
113 | |||
114 | public void ViewerEffectHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock) | ||
115 | { | ||
116 | ViewerEffectPacket packet = new ViewerEffectPacket(); | ||
117 | packet.Effect = effectBlock; | ||
118 | |||
119 | foreach (IClientAPI client in m_clients.Values) | ||
120 | { | ||
121 | if (client.AgentId != sender.AgentId) | ||
122 | { | ||
123 | packet.AgentData.AgentID = client.AgentId; | ||
124 | packet.AgentData.SessionID = client.SessionId; | ||
125 | client.OutPacket(packet); | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | |||
130 | public bool TryGetClient(uint circuitId, out IClientAPI user) | ||
131 | { | ||
132 | return m_clients.TryGetValue(circuitId, out user); | ||
133 | } | ||
134 | } | ||
135 | } \ No newline at end of file | ||