diff options
author | Adam Frisby | 2009-12-27 16:07:05 +1100 |
---|---|---|
committer | Adam Frisby | 2009-12-27 16:07:05 +1100 |
commit | 8a931a4e914a00cbf0e853b83e74e56ace08419e (patch) | |
tree | cae24ef94682d8ba05ea4dfe44b88b2e228b45e0 /OpenSim | |
parent | * Added prebuild for previous commit. (diff) | |
download | opensim-SC-8a931a4e914a00cbf0e853b83e74e56ace08419e.zip opensim-SC-8a931a4e914a00cbf0e853b83e74e56ace08419e.tar.gz opensim-SC-8a931a4e914a00cbf0e853b83e74e56ace08419e.tar.bz2 opensim-SC-8a931a4e914a00cbf0e853b83e74e56ace08419e.tar.xz |
* Implements some basic Sirikata protocol work (initial handshakes).
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs | 21 | ||||
-rw-r--r-- | OpenSim/Client/Sirikata/SirikataModule.cs | 37 |
2 files changed, 57 insertions, 1 deletions
diff --git a/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs b/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs index 78f231a..e8d1889 100644 --- a/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs +++ b/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs | |||
@@ -1,6 +1,7 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Net; | 3 | using System.Net; |
4 | using System.Net.Sockets; | ||
4 | using System.Text; | 5 | using System.Text; |
5 | using OpenMetaverse; | 6 | using OpenMetaverse; |
6 | using OpenMetaverse.Packets; | 7 | using OpenMetaverse.Packets; |
@@ -11,6 +12,26 @@ namespace OpenSim.Client.Sirikata.ClientStack | |||
11 | { | 12 | { |
12 | class SirikataClientView : IClientAPI, IClientCore | 13 | class SirikataClientView : IClientAPI, IClientCore |
13 | { | 14 | { |
15 | private readonly NetworkStream stream; | ||
16 | |||
17 | public SirikataClientView(TcpClient client) | ||
18 | { | ||
19 | stream = client.GetStream(); | ||
20 | |||
21 | sessionId = UUID.Random(); | ||
22 | |||
23 | |||
24 | // Handshake with client | ||
25 | string con = "SSTTCP01" + sessionId; | ||
26 | byte[] handshake = Util.UTF8.GetBytes(con); | ||
27 | |||
28 | byte[] clientHandshake = new byte[2+6+36]; | ||
29 | |||
30 | stream.Read(clientHandshake, 0, handshake.Length); | ||
31 | stream.Write(handshake, 0, handshake.Length - 1); // Remove null terminator (hence the -1) | ||
32 | } | ||
33 | |||
34 | |||
14 | #region Implementation of IClientAPI | 35 | #region Implementation of IClientAPI |
15 | 36 | ||
16 | private Vector3 startPos; | 37 | private Vector3 startPos; |
diff --git a/OpenSim/Client/Sirikata/SirikataModule.cs b/OpenSim/Client/Sirikata/SirikataModule.cs index d2d7ff8..cbb6c23 100644 --- a/OpenSim/Client/Sirikata/SirikataModule.cs +++ b/OpenSim/Client/Sirikata/SirikataModule.cs | |||
@@ -60,8 +60,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
60 | 60 | ||
61 | using System; | 61 | using System; |
62 | using System.Collections.Generic; | 62 | using System.Collections.Generic; |
63 | using System.Net; | ||
64 | using System.Net.Sockets; | ||
63 | using Nini.Config; | 65 | using Nini.Config; |
64 | using OpenMetaverse; | 66 | using OpenMetaverse; |
67 | using OpenSim.Client.Sirikata.ClientStack; | ||
65 | using OpenSim.Framework; | 68 | using OpenSim.Framework; |
66 | using OpenSim.Framework.Servers; | 69 | using OpenSim.Framework.Servers; |
67 | using OpenSim.Framework.Servers.HttpServer; | 70 | using OpenSim.Framework.Servers.HttpServer; |
@@ -72,18 +75,50 @@ namespace OpenSim.Client.Sirikata | |||
72 | { | 75 | { |
73 | class SirikataModule : IRegionModule | 76 | class SirikataModule : IRegionModule |
74 | { | 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 | |||
75 | #region Implementation of IRegionModule | 86 | #region Implementation of IRegionModule |
76 | 87 | ||
77 | public void Initialise(Scene scene, IConfigSource source) | 88 | public void Initialise(Scene scene, IConfigSource source) |
78 | { | 89 | { |
79 | 90 | lock (m_scenes) | |
91 | m_scenes.Add(scene); | ||
80 | } | 92 | } |
81 | 93 | ||
82 | public void PostInitialise() | 94 | public void PostInitialise() |
83 | { | 95 | { |
96 | if(!m_enabled) | ||
97 | return; | ||
98 | |||
99 | m_listener = new TcpListener(IPAddress.Any, 5943); | ||
84 | 100 | ||
85 | } | 101 | } |
86 | 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 | |||
87 | public void Close() | 122 | public void Close() |
88 | { | 123 | { |
89 | 124 | ||