* Implements some basic Sirikata protocol work (initial handshakes).
parent
8e18762e22
commit
8a931a4e91
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
|
@ -11,6 +12,26 @@ namespace OpenSim.Client.Sirikata.ClientStack
|
|||
{
|
||||
class SirikataClientView : IClientAPI, IClientCore
|
||||
{
|
||||
private readonly NetworkStream stream;
|
||||
|
||||
public SirikataClientView(TcpClient client)
|
||||
{
|
||||
stream = client.GetStream();
|
||||
|
||||
sessionId = UUID.Random();
|
||||
|
||||
|
||||
// Handshake with client
|
||||
string con = "SSTTCP01" + sessionId;
|
||||
byte[] handshake = Util.UTF8.GetBytes(con);
|
||||
|
||||
byte[] clientHandshake = new byte[2+6+36];
|
||||
|
||||
stream.Read(clientHandshake, 0, handshake.Length);
|
||||
stream.Write(handshake, 0, handshake.Length - 1); // Remove null terminator (hence the -1)
|
||||
}
|
||||
|
||||
|
||||
#region Implementation of IClientAPI
|
||||
|
||||
private Vector3 startPos;
|
||||
|
|
|
@ -60,8 +60,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Client.Sirikata.ClientStack;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
|
@ -72,18 +75,50 @@ namespace OpenSim.Client.Sirikata
|
|||
{
|
||||
class SirikataModule : IRegionModule
|
||||
{
|
||||
private bool m_enabled = false;
|
||||
|
||||
private TcpListener m_listener;
|
||||
private bool m_running = true;
|
||||
|
||||
private List<Scene> m_scenes = new List<Scene>();
|
||||
private Dictionary<UUID,SirikataClientView> m_clients = new Dictionary<UUID, SirikataClientView>();
|
||||
|
||||
#region Implementation of IRegionModule
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource source)
|
||||
{
|
||||
|
||||
lock (m_scenes)
|
||||
m_scenes.Add(scene);
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
if(!m_enabled)
|
||||
return;
|
||||
|
||||
m_listener = new TcpListener(IPAddress.Any, 5943);
|
||||
|
||||
}
|
||||
|
||||
private void ListenLoop()
|
||||
{
|
||||
while(m_running)
|
||||
{
|
||||
m_listener.BeginAcceptTcpClient(AcceptSocket, m_listener);
|
||||
}
|
||||
}
|
||||
|
||||
private void AcceptSocket(IAsyncResult ar)
|
||||
{
|
||||
TcpListener listener = (TcpListener) ar.AsyncState;
|
||||
TcpClient client = listener.EndAcceptTcpClient(ar);
|
||||
|
||||
SirikataClientView clientView = new SirikataClientView(client);
|
||||
|
||||
lock (m_clients)
|
||||
m_clients.Add(clientView.SessionId, clientView);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
|
||||
|
|
Loading…
Reference in New Issue