Prim creation added. Session authentication moved to Gridserver interface.

standalone
MW 2007-02-18 18:46:04 +00:00
parent d6bf4ede92
commit 31209cdab9
12 changed files with 240 additions and 123 deletions

View File

@ -38,7 +38,7 @@ namespace OpenSim
public class AgentManager
{
public Dictionary<libsecondlife.LLUUID,AgentProfile> AgentList;
private uint _localNumber=0;
private uint _localAvatarNumber=0;
private Server _server;
public AgentManager(Server server)
@ -108,8 +108,8 @@ namespace OpenSim
agent.Avatar.Position = new LLVector3(100, 100, 22);
agent.Avatar.BaseFolder = baseFolder;
agent.Avatar.InventoryFolder = inventoryFolder;
agent.Avatar.LocalID = 8880000 + this._localNumber;
this._localNumber++;
agent.Avatar.LocalID = 8880000 + this._localAvatarNumber;
this._localAvatarNumber++;
this.AgentList.Add(agent.Avatar.FullID, agent);
//Create new Wearable Assets and place in Inventory

View File

@ -46,13 +46,13 @@ namespace OpenSim
public List<AssetRequest> RequestedAssets = new List<AssetRequest>(); //Assets requested from the asset server
public List<TextureRequest> RequestedTextures = new List<TextureRequest>(); //Textures requested from the asset server
private AssetServer _assetServer;
private IAssetServer _assetServer;
private Server _server;
/// <summary>
///
/// </summary>
public AssetManager(Server server, AssetServer assetServer)
public AssetManager(Server server, IAssetServer assetServer)
{
_server = server;
_assetServer = assetServer;

View File

@ -60,6 +60,7 @@ namespace OpenSim
public class PrimData : Node
{
public LLUUID OwnerID;
public LLUUID FullID;
public uint LocalID;
public byte PCode;
public byte PathBegin;
@ -76,11 +77,13 @@ namespace OpenSim
public byte ProfileCurve;
public uint ParentID=0;
public byte ProfileHollow;
public uint AddFlags;
public libsecondlife.LLObject.TextureEntry Texture;
//public bool DataBaseStorage=false;
public PrimData()
{
this.SceneType = 2;
}
public void FromBytes(byte[] bytes)

View File

@ -42,7 +42,8 @@ namespace OpenSim
public static SceneGraph Scene;
public static AgentManager AgentManager;
public static PrimManager PrimManager;
public static UserServer UserServer;
public static IUserServer UserServer;
public static IGridServer GridServer;
public byte ConnectionType=1;
private bool _authorised = false;
@ -74,7 +75,7 @@ namespace OpenSim
//should check that this session/circuit is authorised
UseCircuitCodePacket circuitPacket=(UseCircuitCodePacket)packet;
AuthenticateResponse sessionInfo = UserServer.AuthenticateSession(circuitPacket.CircuitCode.SessionID, circuitPacket.CircuitCode.ID, circuitPacket.CircuitCode.Code);
AuthenticateResponse sessionInfo = GridServer.AuthenticateSession(circuitPacket.CircuitCode.SessionID, circuitPacket.CircuitCode.ID, circuitPacket.CircuitCode.Code);
if(!sessionInfo.Authorised)
{
//session/circuit not authorised
@ -113,6 +114,11 @@ namespace OpenSim
AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
Scene.AvatarMovementCommand(this.NetInfo, agentUpdate);
break;
case PacketType.ObjectAdd:
Console.WriteLine("received add object packet");
PrimAsset prim = PrimManager.CreateNewPrim(this.NetInfo, (ObjectAddPacket) packet);
Scene.AddNewPrim(prim.PrimData);
break;
default:
break;
}

View File

@ -70,21 +70,24 @@ namespace OpenSim
_gridManager = new GridManager(_viewerServer, _agentManager);
_scene = new SceneGraph(_viewerServer, _agentManager);
_assetManager = new AssetManager(_viewerServer, _backboneServers.AssetServer);
_primManager = new PrimManager();
ClientConnection.Grid = _gridManager;
ClientConnection.Scene = _scene;
ClientConnection.AgentManager = _agentManager;
ClientConnection.PrimManager = _primManager;
ClientConnection.UserServer = _backboneServers.UserServer;
ClientConnection.GridServer = _backboneServers.GridServer;
_viewerServer.Startup();
BerkeleyDatabases.Instance.Startup();
_primManager = new PrimManager();
if(Globals.Instance.StartLoginServer)
{
_loginServer = new LoginServer(_backboneServers.UserServer);
_loginServer = new LoginServer(_backboneServers.GridServer);
_loginServer.Startup();
}
timer1.Enabled = true;
timer1.Interval = 200;
timer1.Interval = 125;
timer1.Elapsed +=new ElapsedEventHandler( this.Timer1Tick );
}
@ -110,15 +113,15 @@ namespace OpenSim
public class BackboneServers
{
public GridServer GridServer;
public UserServer UserServer;
public AssetServer AssetServer;
public IGridServer GridServer;
public IUserServer UserServer;
public IAssetServer AssetServer;
public BackboneServers()
{
this.GridServer = new GridServer();
this.UserServer = new UserServer();
this.AssetServer = new AssetServer();
this.GridServer = (IGridServer) new GridServer();
this.UserServer =(IUserServer) new UserServer();
this.AssetServer =(IAssetServer) new AssetServer();
}
}
}

View File

@ -26,6 +26,7 @@
*/
using System;
using System.Collections.Generic;
using libsecondlife;
namespace OpenSim
@ -36,8 +37,43 @@ namespace OpenSim
/// </summary>
public class GridServer //:IGridServer
{
public List<Logon> Sessions = new List<Logon>(); //should change to something other than logon classes?
public GridServer()
{
Sessions = new List<Logon>();
}
public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
{
//For Grid use:
//should check to see if it is a teleportation, if so then we should be expecting this session, agent. (?)
//if not check with User server/ login server that it is authorised.
//but for now we are running local
AuthenticateResponse user = new AuthenticateResponse();
lock(this.Sessions)
{
for(int i = 0; i < Sessions.Count; i++)
{
if((Sessions[i].Agent == agentID) && (Sessions[i].Session == sessionID))
{
user.Authorised = true;
user.LogonInfo = Sessions[i];
}
}
}
return(user);
}
public void AddNewSession(Logon session)
{
lock(this.Sessions)
{
this.Sessions.Add(session);
}
}
}
@ -46,6 +82,8 @@ namespace OpenSim
bool RequestConnection(RegionInfo myRegion);
UUIDBlock RequestUUIDBlock();
RegionInfo[] RequestNeighbours();
AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
void AddNewSession(Logon session);
}
public struct UUIDBlock
@ -54,5 +92,16 @@ namespace OpenSim
public LLUUID BlockEnd;
}
public class AuthenticateResponse
{
public bool Authorised;
public Logon LogonInfo;
public AuthenticateResponse()
{
}
}
}

View File

@ -44,12 +44,12 @@ namespace OpenSim
/// </summary>
public class LoginServer
{
public LoginServer(UserServer userServer)
public LoginServer(IGridServer gridServer)
{
_userServer = userServer;
_gridServer = gridServer;
}
private Logon _login;
private UserServer _userServer;
private IGridServer _gridServer;
private ushort _loginPort = Globals.Instance.LoginServerPort;
public IPAddress clientAddress = IPAddress.Loopback;
public IPAddress remoteAddress = IPAddress.Any;
@ -246,11 +246,8 @@ namespace OpenSim
_login.BaseFolder = BaseFolderID;
_login.InventoryFolder = InventoryFolderID;
//working on local computer so lets add to the userserver's list of sessions
lock(this._userServer.Sessions)
{
this._userServer.Sessions.Add(_login);
}
//working on local computer so lets add to the gridserver's list of sessions
this._gridServer.AddNewSession(_login);
// forward the XML-RPC response to the client
writer.WriteLine("HTTP/1.0 200 OK");

View File

@ -26,7 +26,10 @@
*/
using System;
using System.IO;
using System.Collections.Generic;
using libsecondlife;
using libsecondlife.Packets;
namespace OpenSim
{
@ -36,30 +39,59 @@ namespace OpenSim
public class PrimManager
{
private LocalPrimDb _localPrimDB;
private int _localPrimNumber;
private Dictionary<libsecondlife.LLUUID,PrimAsset> PrimList;
public PrimManager()
{
this._localPrimDB = new LocalPrimDb();
this.PrimList = new Dictionary<libsecondlife.LLUUID,PrimAsset>();
}
/// <summary>
/// Called when a prim is created in-world
/// </summary>
/// <param name="userInfo"></param>
/// <param name="addPacket"></param>
/// <returns></returns>
public PrimAsset CreateNewPrim(NetworkInfo userInfo, ObjectAddPacket addPacket)
{
PrimData PData = new PrimData();
PData.OwnerID = userInfo.User.AgentID;
PData.PCode = addPacket.ObjectData.PCode;
PData.PathBegin = addPacket.ObjectData.PathBegin;
PData.PathEnd = addPacket.ObjectData.PathEnd;
PData.PathScaleX = addPacket.ObjectData.PathScaleX;
PData.PathScaleY = addPacket.ObjectData.PathScaleY;
PData.PathShearX = addPacket.ObjectData.PathShearX;
PData.PathShearY = addPacket.ObjectData.PathShearY;
PData.PathSkew = addPacket.ObjectData.PathSkew;
PData.ProfileBegin = addPacket.ObjectData.ProfileBegin;
PData.ProfileEnd = addPacket.ObjectData.ProfileEnd;
PData.Scale = addPacket.ObjectData.Scale;
PData.PathCurve = addPacket.ObjectData.PathCurve;
PData.ProfileCurve = addPacket.ObjectData.ProfileCurve;
PData.ParentID = 0;
PData.ProfileHollow = addPacket.ObjectData.ProfileHollow;
PData.AddFlags = addPacket.ObjectData.AddFlags;
//database test
/*PrimAsset prim = new PrimAsset();
prim.Name="happy now";
prim.Description= "test";
prim.FullID = new LLUUID("00000000-0000-0000-0000-000000000008");
prim.Data= new byte[10];
prim.Data[0]=5;
prim.Data[1]=4;
prim.Data[2]=5;
prim.Data[3]=6;
prim.Data[4]=5;
this._localPrimDB.CreateNewPrimStorage(prim);
//finish off copying rest of shape data
PData.LocalID = (uint)(702000 + _localPrimNumber);
PData.FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efefd"+_localPrimNumber.ToString("0000"));
PData.Position = addPacket.ObjectData.RayEnd;
_localPrimNumber++;
PrimAsset prim1 = this._localPrimDB.GetPrimFromStroage( new LLUUID("00000000-0000-0000-0000-000000000008"));
Console.WriteLine("prim received : "+prim1.Name + " "+ prim1.Description);
Console.WriteLine("received prims data length is: "+prim1.Data.Length);
Console.WriteLine(Helpers.FieldToString(prim1.Data));
//this._localPrimDB.ReadWholedatabase();
*/
//for now give it a default texture
PData.Texture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
PrimAsset prim = new PrimAsset();
prim.FullID = PData.FullID;
prim.PrimData = PData;
this.PrimList.Add(prim.FullID, prim);
//should copy to local prim database (and at some point upload to the asset server)
return(prim);
}
}

View File

@ -48,6 +48,8 @@ namespace OpenSim
private Server _server;
private System.Text.Encoding _enc = System.Text.Encoding.ASCII;
private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock _avatarTemplate;
private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock PrimTemplate;
private int _objectCount=0;
private UpdateSender _updateSender;
private AgentManager _agentManager;
@ -70,7 +72,8 @@ namespace OpenSim
_updateSender = new UpdateSender(_server, agentManager);
_agentManager = agentManager;
//testing
this.SetupTemplate("objectupate168.dat");
this.SetupAvatarTemplate("objectupate168.dat");
this.SetupObjectTemplate("objectupate164.dat");
_updateSender.Startup();
}
@ -145,7 +148,7 @@ namespace OpenSim
int updatemask = avatar.UpdateFlag & (128);
if(updatemask == 128) //is a new avatar?
{
Console.WriteLine("new avatar has been added to scene so update it on the current scene");
//Console.WriteLine("new avatar has been added to scene so update it on the current scene");
this.SendAvatarDataToAll(avatar);
@ -160,6 +163,24 @@ namespace OpenSim
}
}
//check for new prims
lock(this.RootNode)
{
for (int i = 0; i < this.RootNode.ChildrenCount; i++)
{
if(this.RootNode.GetChild(i).SceneType == 2) //check it is a prim node
{
PrimData prim =(PrimData) this.RootNode.GetChild(i);
if((prim.UpdateFlag & (64)) == 64)
{
//send prim data to all clients
this.SendPrimToAll(prim);
}
}
}
}
//send updates to clients
//might be better to do these updates reverse to how is done here
// ie.. loop through the avatars and find objects /other avatars in their range/vision
@ -241,9 +262,8 @@ namespace OpenSim
newCommand.Velocity.X = direc.x;
newCommand.Velocity.Y = direc.y;
newCommand.Velocity.Z = direc.z;
//avatar.Walk = true;
//work out velocity for internal clients movement commands
//work out velocity for clients movement commands
internDirec = internDirec * (0.03f);
internDirec.x += 1;
internDirec.y += 1;
@ -266,7 +286,6 @@ namespace OpenSim
newCommand.CommandType = 1;
newCommand.SObject = avatar;
//walking but key not pressed so need to stop
//avatar.Walk = false;
newCommand.Velocity.X = 0;
newCommand.Velocity.Y = 0;
newCommand.Velocity.Z = 0;
@ -355,35 +374,20 @@ namespace OpenSim
}
#region testing
//test only
private void SendAvatarData(NetworkInfo userInfo)
public void AddNewPrim(PrimData prim)
{
ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle = Globals.Instance.RegionHandle;
objupdate.RegionData.TimeDilation = 64096;
objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
objupdate.ObjectData[0] = _avatarTemplate;
//give this avatar object a local id and assign the user a name
objupdate.ObjectData[0].ID = 8880000;// + this._localNumber;
userInfo.User.AvatarLocalID = objupdate.ObjectData[0].ID;
//User_info.name="Test"+this.local_numer+" User";
//this.GetAgent(userInfo.UserAgentID).Started = true;
objupdate.ObjectData[0].FullID = userInfo.User.AgentID;
objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + userInfo.User.FirstName + "\nLastName STRING RW SV " + userInfo.User.LastName + " \0");
//userInfo.User.FullName = "FirstName STRING RW SV " + userInfo.first_name + "\nLastName STRING RW SV " + userInfo.last_name + " \0";
libsecondlife.LLVector3 pos2 = new LLVector3(100f, 100.0f, 22.0f);
byte[] pb = pos2.GetBytes();
Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
//this._localNumber++;
_server.SendPacket(objupdate, true, userInfo);
lock(this.RootNode)
{
prim.SceneName = "Prim" + this._objectCount.ToString("00000"); //not sure why still doing this as its not used
this._objectCount++;
this.RootNode.AddChild(prim);
}
prim.UpdateFlag = 64;
}
#region temporary template
//test only
private void SetupTemplate(string name)
//temporary only
private void SetupAvatarTemplate(string name)
{
//should be replaced with completely code generated packets
int i = 0;
@ -409,6 +413,26 @@ namespace OpenSim
_avatarTemplate = objdata;
}
//really really need to get rid of these templates
public void SetupObjectTemplate(string name)
{
int i = 0;
FileInfo fInfo = new FileInfo(name);
long numBytes = fInfo.Length;
FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fStream);
byte [] data1 = br.ReadBytes((int)numBytes);
br.Close();
fStream.Close();
libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i);
this.PrimTemplate = objdata;
objdata.UpdateFlags = objdata.UpdateFlags + 12 - 16 + 32 + 256;
objdata.OwnerID = new LLUUID("00000000-0000-0000-0000-000000000000");
//test adding a new texture to object , to test image downloading
}
#endregion
private void SendAvatarDataToAll(AvatarData avatar)
@ -441,6 +465,49 @@ namespace OpenSim
}
public void SendPrimToAll(PrimData prim)
{
PrimData PData = prim;
ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle = Globals.Instance.RegionHandle;
objupdate.RegionData.TimeDilation = 0;
objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
objupdate.ObjectData[0] = this.PrimTemplate;
objupdate.ObjectData[0].OwnerID = PData.OwnerID;
objupdate.ObjectData[0].PCode = PData.PCode;
objupdate.ObjectData[0].PathBegin = PData.PathBegin;
objupdate.ObjectData[0].PathEnd = PData.PathEnd;
objupdate.ObjectData[0].PathScaleX = PData.PathScaleX;
objupdate.ObjectData[0].PathScaleY = PData.PathScaleY;
objupdate.ObjectData[0].PathShearX = PData.PathShearX;
objupdate.ObjectData[0].PathShearY = PData.PathShearY;
objupdate.ObjectData[0].PathSkew = PData.PathSkew;
objupdate.ObjectData[0].ProfileBegin = PData.ProfileBegin;
objupdate.ObjectData[0].ProfileEnd = PData.ProfileEnd;
objupdate.ObjectData[0].Scale = PData.Scale;
objupdate.ObjectData[0].PathCurve = PData.PathCurve;
objupdate.ObjectData[0].ProfileCurve = PData.ProfileCurve;
objupdate.ObjectData[0].ParentID = PData.ParentID ;
objupdate.ObjectData[0].ProfileHollow = PData.ProfileHollow ;
objupdate.ObjectData[0].TextureEntry = PData.Texture.ToBytes();
objupdate.ObjectData[0].ID = PData.LocalID;
objupdate.ObjectData[0].FullID = PData.FullID;
//update position
byte[] pb = PData.Position.GetBytes();
Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
SendInfo send = new SendInfo();
send.Incr = true;
send.NetInfo = null;
send.Packet = objupdate;
send.SentTo = 1; //to all clients
this._updateSender.SendList.Enqueue(send);
}
public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock(AvatarData avatar)
{
byte[] bytes = new byte[60];
@ -455,57 +522,47 @@ namespace OpenSim
bytes[i++] = (byte)((ID >> 8) % 256);
bytes[i++] = (byte)((ID >> 16) % 256);
bytes[i++] = (byte)((ID >> 24) % 256);
bytes[i++] = 0;
bytes[i++] = 1;
i += 14;
bytes[i++] = 128;
bytes[i++] = 63;
byte[] pb = pos2.GetBytes();
byte[] pb = pos2.GetBytes();
Array.Copy(pb, 0, bytes, i, pb.Length);
i += 12;
ushort ac = 32767;
bytes[i++] = (byte)(avatar.InternVelocityX % 256);
bytes[i++] = (byte)((avatar.InternVelocityX >> 8) % 256);
bytes[i++] = (byte)(avatar.InternVelocityY % 256);
bytes[i++] = (byte)((avatar.InternVelocityY>> 8) % 256);
bytes[i++] = (byte)(avatar.InternVelocityZ % 256);
bytes[i++] = (byte)((avatar.InternVelocityZ >> 8) % 256);
//accel
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
//rot
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
//rotation vel
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);

View File

@ -37,10 +37,8 @@ namespace OpenSim
/// </summary>
public class UserServer :IUserServer
{
public List<Logon> Sessions = new List<Logon>(); //should change to something other than logon classes?
public UserServer()
{
Sessions = new List<Logon>();
}
private void Initialise()
@ -52,45 +50,17 @@ namespace OpenSim
}
}
public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
public void test()
{
//For Grid use:
//should check to see if it is a teleportation, if so then we should be expecting this session, agent. (?)
//if not check with User server/ login server that it is authorised.
//but for now we are running local
AuthenticateResponse user = new AuthenticateResponse();
lock(this.Sessions)
{
for(int i = 0; i < Sessions.Count; i++)
{
if((Sessions[i].Agent == agentID) && (Sessions[i].Session == sessionID))
{
user.Authorised = true;
user.LogonInfo = Sessions[i];
}
}
}
return(user);
}
}
public interface IUserServer
{
AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
void test();
}
public class AuthenticateResponse
{
public bool Authorised;
public Logon LogonInfo;
public AuthenticateResponse()
{
}
}
}

Binary file not shown.

Binary file not shown.