diff options
Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim
Diffstat (limited to 'OpenSim/Client/Sirikata/SirikataModule.cs')
-rw-r--r-- | OpenSim/Client/Sirikata/SirikataModule.cs | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/OpenSim/Client/Sirikata/SirikataModule.cs b/OpenSim/Client/Sirikata/SirikataModule.cs new file mode 100644 index 0000000..cbb6c23 --- /dev/null +++ b/OpenSim/Client/Sirikata/SirikataModule.cs | |||
@@ -0,0 +1,139 @@ | |||
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 OpenSimulator 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 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | */ | ||
26 | // THIS MODULE USES CODE FROM SIRIKATA, THE SIRIKATA LICENSE IS BELOW | ||
27 | /* | ||
28 | Sirikata is Licensed using the revised BSD license. | ||
29 | If you have any questions, contact Patrick Horn at <patrick.horn@gmail.com> | ||
30 | |||
31 | |||
32 | Copyright (c) 2008, the Sirikata developers (see AUTHORS file for credit). | ||
33 | All rights reserved. | ||
34 | |||
35 | Redistribution and use in source and binary forms, with or without | ||
36 | modification, are permitted provided that the following conditions are | ||
37 | met: | ||
38 | * Redistributions of source code must retain the above copyright | ||
39 | notice, this list of conditions and the following disclaimer. | ||
40 | * Redistributions in binary form must reproduce the above copyright | ||
41 | notice, this list of conditions and the following disclaimer in | ||
42 | the documentation and/or other materials provided with the | ||
43 | distribution. | ||
44 | * Neither the name of Sirikata nor the names of its contributors may | ||
45 | be used to endorse or promote products derived from this software | ||
46 | without specific prior written permission. | ||
47 | |||
48 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
49 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
50 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
51 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER | ||
52 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
53 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
54 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
55 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
56 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
57 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
58 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
59 | */ | ||
60 | |||
61 | using System; | ||
62 | using System.Collections.Generic; | ||
63 | using System.Net; | ||
64 | using System.Net.Sockets; | ||
65 | using Nini.Config; | ||
66 | using OpenMetaverse; | ||
67 | using OpenSim.Client.Sirikata.ClientStack; | ||
68 | using OpenSim.Framework; | ||
69 | using OpenSim.Framework.Servers; | ||
70 | using OpenSim.Framework.Servers.HttpServer; | ||
71 | using OpenSim.Region.Framework.Interfaces; | ||
72 | using OpenSim.Region.Framework.Scenes; | ||
73 | |||
74 | namespace OpenSim.Client.Sirikata | ||
75 | { | ||
76 | class SirikataModule : IRegionModule | ||
77 | { | ||
78 | private bool m_enabled = false; | ||
79 | |||
80 | private TcpListener m_listener; | ||
81 | private bool m_running = true; | ||
82 | |||
83 | private List<Scene> m_scenes = new List<Scene>(); | ||
84 | private Dictionary<UUID,SirikataClientView> m_clients = new Dictionary<UUID, SirikataClientView>(); | ||
85 | |||
86 | #region Implementation of IRegionModule | ||
87 | |||
88 | public void Initialise(Scene scene, IConfigSource source) | ||
89 | { | ||
90 | lock (m_scenes) | ||
91 | m_scenes.Add(scene); | ||
92 | } | ||
93 | |||
94 | public void PostInitialise() | ||
95 | { | ||
96 | if(!m_enabled) | ||
97 | return; | ||
98 | |||
99 | m_listener = new TcpListener(IPAddress.Any, 5943); | ||
100 | |||
101 | } | ||
102 | |||
103 | private void ListenLoop() | ||
104 | { | ||
105 | while(m_running) | ||
106 | { | ||
107 | m_listener.BeginAcceptTcpClient(AcceptSocket, m_listener); | ||
108 | } | ||
109 | } | ||
110 | |||
111 | private void AcceptSocket(IAsyncResult ar) | ||
112 | { | ||
113 | TcpListener listener = (TcpListener) ar.AsyncState; | ||
114 | TcpClient client = listener.EndAcceptTcpClient(ar); | ||
115 | |||
116 | SirikataClientView clientView = new SirikataClientView(client); | ||
117 | |||
118 | lock (m_clients) | ||
119 | m_clients.Add(clientView.SessionId, clientView); | ||
120 | } | ||
121 | |||
122 | public void Close() | ||
123 | { | ||
124 | |||
125 | } | ||
126 | |||
127 | public string Name | ||
128 | { | ||
129 | get { return "Sirikata ClientStack Module"; } | ||
130 | } | ||
131 | |||
132 | public bool IsSharedModule | ||
133 | { | ||
134 | get { return true; } | ||
135 | } | ||
136 | |||
137 | #endregion | ||
138 | } | ||
139 | } | ||