Пример #1
0
        public bool Start(Simian simian)
        {
            m_simian = simian;
            m_userClient = m_simian.GetAppModule<IUserClient>();

            // Library user and inventory creation
            string libraryOwnerName = "Library Owner";
            IConfig config = simian.Config.Configs["StandaloneInventoryClient"];
            if (config != null)
            {
                libraryOwnerName = config.GetString("LibraryOwnerName", "Library Owner");
            }
            CreateLibrary(libraryOwnerName);

            // Deserialize inventories from disk
            m_fileDataStore = m_simian.GetAppModule<FileDataStore>();
            if (m_fileDataStore != null)
            {
                IList<SerializedData> inventories = m_fileDataStore.Deserialize(UUID.Zero, "Inventory");
                for (int i = 0; i < inventories.Count; i++)
                {
                    string name = inventories[i].Name;

                    UUID ownerID;
                    if (UUID.TryParse(name, out ownerID))
                    {
                        OSDMap map = null;
                        try { map = OSDParser.Deserialize(inventories[i].Data) as OSDMap; }
                        catch (Exception) { }

                        if (map != null)
                            DeserializeInventory(ownerID, map);
                        else
                            m_log.Warn("Failed to deserialize inventory file " + name);
                    }
                }
            }

            return true;
        }
Пример #2
0
        public bool Start(Simian simian)
        {
            m_simian = simian;

            m_scheduler = m_simian.GetAppModule<IScheduler>();
            if (m_scheduler == null)
            {
                m_log.Error("StandaloneAssetClient requires an IScheduler service");
                return false;
            }

            m_dataStore = m_simian.GetAppModule<IDataStore>();
            if (m_dataStore == null)
            {
                m_log.Error("StandaloneAssetClient requires an IDataStore service");
                return false;
            }

            LoadDefaultAssets();

            return true;
        }
        public bool Start(Simian simian)
        {
            m_simian = simian;
            m_userClient = m_simian.GetAppModule<IUserClient>();

            IConfigSource source = simian.Config;
            IConfig config = source.Configs["SimianGrid"];
            if (config != null)
                m_serverUrl = config.GetString("InventoryService", null);

            if (String.IsNullOrEmpty(m_serverUrl))
            {
                m_log.Error("[SimianGrid] config section is missing the InventoryService URL");
                return false;
            }

            return true;
        }
Пример #4
0
        public bool Start(Simian simian)
        {
            m_fileDataStore = simian.GetAppModule<FileDataStore>();
            if (m_fileDataStore != null)
            {
                IList<SerializedData> users = m_fileDataStore.Deserialize(UUID.Zero, "Users");
                for (int i = 0; i < users.Count; i++)
                {
                    string name = users[i].Name;
                    UUID ownerID;

                    OSDMap map = null;
                    try { map = OSDParser.Deserialize(users[i].Data) as OSDMap; }
                    catch (Exception) { }

                    if (name == "identities")
                    {
                        if (map != null)
                            DeserializeIdentities(map);
                        else
                            m_log.Warn("Failed to deserialize user identity file");
                    }
                    else if (UUID.TryParse(name, out ownerID))
                    {
                        if (map != null)
                            DeserializeUser(map);
                        else
                            m_log.Warn("Failed to deserialize user file " + name);
                    }
                }
            }

            return true;
        }
Пример #5
0
        public bool Start(Simian simian)
        {
            m_simian = simian;

            m_httpServer = simian.GetAppModule<IHttpServer>();
            if (m_httpServer == null)
            {
                m_log.Error("StandaloneGridClient requires an IHttpServer");
                return false;
            }

            m_sceneFactory = simian.GetAppModule<ISceneFactory>();
            if (m_sceneFactory == null)
            {
                m_log.Error("StandaloneGridClient requires an ISceneFactory");
                return false;
            }

            m_assetClient = simian.GetAppModule<IAssetClient>();

            return true;
        }
Пример #6
0
        public bool Start(Simian simian)
        {
            m_simian = simian;

            #region Get Module References

            m_httpServer = simian.GetAppModule<IHttpServer>();
            if (m_httpServer == null)
            {
                m_log.Error("Can't create the LindenLogin service without an HTTP server");
                return false;
            }

            m_userClient = simian.GetAppModule<IUserClient>();
            if (m_userClient == null)
            {
                m_log.Error("Can't create the LindenLogin service without a user client");
                return false;
            }

            m_gridClient = simian.GetAppModule<IGridClient>();
            if (m_gridClient == null)
            {
                m_log.Error("Can't create the LindenLogin service without a grid client");
                return false;
            }

            m_inventoryClient = simian.GetAppModule<IInventoryClient>();

            #endregion Get Module References

            m_httpServer.AddXmlRpcHandler("/", true, "login_to_simulator", LoginHandler);
            m_log.Info("LindenLogin handler initialized");

            return true;
        }
Пример #7
0
        public bool Start(Simian simian)
        {
            m_simian = simian;

            if (File.Exists("motd.txt"))
            {
                m_motd = File.ReadAllLines("motd.txt");
            }

            else
            {
                m_motd = new string[0];
            }

            m_sceneFactory = m_simian.GetAppModule <ISceneFactory>();
            if (m_sceneFactory != null)
            {
                m_sceneFactory.OnSceneStart += SceneStartHandler;
            }

            m_clientConnectedCallback = new AsyncCallback(
                delegate(IAsyncResult ar)
            {
                if (m_scene == null)
                {
                    return;
                }

                try
                {
                    //accept connection for a new user
                    IRCUser user   = new IRCUser(m_scene, null, UUID.Random());
                    user.TCPClient = m_listener.EndAcceptTcpClient(ar);
                    m_log.Info("Connection from " + user.TCPClient.Client.RemoteEndPoint);

                    //add new user to dictionary
                    m_users.Add(user);

                    //begin listening for data on the new connection, and also for the next client connection
                    user.TCPClient.Client.BeginReceive(user.Buffer, 0, TCP_BUFFER_LENGTH, SocketFlags.None, m_dataReceivedCallback, user);
                    m_listener.BeginAcceptTcpClient(m_clientConnectedCallback, user);

                    //fire ClientConnected event
                    if (ClientConnected != null)
                    {
                        ClientConnected(user);
                    }
                }
                catch (ObjectDisposedException) { }
            }
                );

            m_dataReceivedCallback = new AsyncCallback(
                delegate(IAsyncResult ar)
            {
                IRCUser user = (IRCUser)ar.AsyncState;

                //number of bytes read
                int bytesRead = user.TCPClient.Client.EndReceive(ar);

                //name or address, depending on whether or not user is authenticated
                string displayName = user.Name == null ? user.TCPClient.Client.RemoteEndPoint.ToString() : user.Name;

                //check for disconnection
                if (bytesRead == 0 || !user.TCPClient.Client.Connected)
                {
                    m_log.Info("Client " + displayName + " disconnected.");

                    SendToUserChannels(user, IRCMessageType.Quit, "Disconnected");     //TODO: quit messages

                    //remove user from disctionary
                    RemoveUser(user);

                    //fire ClientDisconnected event
                    if (ClientDisconnected != null)
                    {
                        ClientDisconnected(user, null);
                    }

                    return;
                }

                //trim buffer length to the number of bytes read
                byte[] buffer = new byte[bytesRead];
                Array.Copy(user.Buffer, 0, buffer, 0, bytesRead);

                //split message into string lines
                string[] delimiters = new string[] { "\0", "\r", "\n" };
                string[] lines      = Encoding.ASCII.GetString(buffer).Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

                //parse each line
                for (int i = 0, len = lines.Length; i < len; i++)
                {
                    m_log.Info("<" + displayName + ">: " + lines[i]);

                    //fire DataReceived event
                    if (DataReceived != null)
                    {
                        DataReceived(user, lines[i]);
                    }

                    ParseCommand(user, lines[i]);
                }

                //keep listening for data
                try
                {
                    user.TCPClient.Client.BeginReceive(user.Buffer, 0, TCP_BUFFER_LENGTH, SocketFlags.None, m_dataReceivedCallback, user);
                }
                catch (Exception ex)
                {
                    m_log.Warn(ex.Message);
                    RemoveUser(user);
                }
            }
                );

            try
            {
                m_listener = new TcpListener(IPAddress.Any, 6667);
                m_listener.Start();
                m_listener.BeginAcceptTcpClient(m_clientConnectedCallback, this);
            }
            catch (Exception ex)
            {
                m_log.Error("Failed to start IRC server: " + ex.Message);
                return(false);
            }

            m_log.Info("IRC server listening on port 6667");
            return(true);
        }
Пример #8
0
        public bool Start(Simian simian)
        {
            m_simian = simian;
            m_httpServer = simian.GetAppModule<IHttpServer>();
            m_dataStore = m_simian.GetAppModule<IDataStore>();

            IConfigSource source = simian.Config;
            IConfig config = source.Configs["SimianGrid"];
            if (config != null)
                m_serverUrl = config.GetString("AssetService", null);

            if (String.IsNullOrEmpty(m_serverUrl))
            {
                m_log.Error("[SimianGrid] config section is missing the AssetService URL");
                return false;
            }

            return true;
        }
Пример #9
0
        public bool Start(Simian simian)
        {
            IConfigSource source = simian.Config;
            IConfig config = source.Configs["SimianGrid"];
            if (config != null)
                m_serverUrl = config.GetString("UserService", null);

            if (String.IsNullOrEmpty(m_serverUrl))
            {
                m_log.Error("[SimianGrid] config section is missing the UserService URL");
                return false;
            }

            m_fileDataStore = simian.GetAppModule<FileDataStore>();

            return true;
        }
Пример #10
0
        private bool m_useAntiAliasing             = true; // TODO: Make this a config option

        public bool Start(Simian simian)
        {
            m_assetClient = simian.GetAppModule <IAssetClient>();

            return(true);
        }
Пример #11
0
        public bool Start(Simian simian)
        {
            m_simian = simian;

            if (File.Exists("motd.txt"))
                m_motd = File.ReadAllLines("motd.txt");

            else m_motd = new string[0];

            m_sceneFactory = m_simian.GetAppModule<ISceneFactory>();
            if (m_sceneFactory != null)
            {
                m_sceneFactory.OnSceneStart += SceneStartHandler;
            }

            m_clientConnectedCallback = new AsyncCallback(
                delegate(IAsyncResult ar)
                {
                    if (m_scene == null)
                        return;

                    try
                    {
                        //accept connection for a new user
                        IRCUser user = new IRCUser(m_scene, null, UUID.Random());
                        user.TCPClient = m_listener.EndAcceptTcpClient(ar);
                        m_log.Info("Connection from " + user.TCPClient.Client.RemoteEndPoint);

                        //add new user to dictionary
                        m_users.Add(user);

                        //begin listening for data on the new connection, and also for the next client connection
                        user.TCPClient.Client.BeginReceive(user.Buffer, 0, TCP_BUFFER_LENGTH, SocketFlags.None, m_dataReceivedCallback, user);
                        m_listener.BeginAcceptTcpClient(m_clientConnectedCallback, user);

                        //fire ClientConnected event
                        if (ClientConnected != null)
                            ClientConnected(user);
                    }
                    catch (ObjectDisposedException) { }
                }
            );

            m_dataReceivedCallback = new AsyncCallback(
                delegate(IAsyncResult ar)
                {
                    IRCUser user = (IRCUser)ar.AsyncState;

                    //number of bytes read
                    int bytesRead = user.TCPClient.Client.EndReceive(ar);

                    //name or address, depending on whether or not user is authenticated
                    string displayName = user.Name == null ? user.TCPClient.Client.RemoteEndPoint.ToString() : user.Name;

                    //check for disconnection
                    if (bytesRead == 0 || !user.TCPClient.Client.Connected)
                    {
                        m_log.Info("Client " + displayName + " disconnected.");

                        SendToUserChannels(user, IRCMessageType.Quit, "Disconnected"); //TODO: quit messages

                        //remove user from disctionary
                        RemoveUser(user);

                        //fire ClientDisconnected event
                        if (ClientDisconnected != null)
                            ClientDisconnected(user, null);

                        return;
                    }

                    //trim buffer length to the number of bytes read
                    byte[] buffer = new byte[bytesRead];
                    Array.Copy(user.Buffer, 0, buffer, 0, bytesRead);

                    //split message into string lines
                    string[] delimiters = new string[] { "\0", "\r", "\n" };
                    string[] lines = Encoding.ASCII.GetString(buffer).Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

                    //parse each line
                    for (int i = 0, len = lines.Length; i < len; i++)
                    {
                        m_log.Info("<" + displayName + ">: " + lines[i]);

                        //fire DataReceived event
                        if (DataReceived != null)
                            DataReceived(user, lines[i]);

                        ParseCommand(user, lines[i]);
                    }

                    //keep listening for data
                    try
                    {
                        user.TCPClient.Client.BeginReceive(user.Buffer, 0, TCP_BUFFER_LENGTH, SocketFlags.None, m_dataReceivedCallback, user);
                    }
                    catch (Exception ex)
                    {
                        m_log.Warn(ex.Message);
                        RemoveUser(user);
                    }
                }
            );

            try
            {
                m_listener = new TcpListener(IPAddress.Any, 6667);
                m_listener.Start();
                m_listener.BeginAcceptTcpClient(m_clientConnectedCallback, this);
            }
            catch (Exception ex)
            {
                m_log.Error("Failed to start IRC server: " + ex.Message);
                return false;
            }

            m_log.Info("IRC server listening on port 6667");
            return true;
        }
Пример #12
0
        public bool Start(Simian simian)
        {
            m_scheduler = simian.GetAppModule<IScheduler>();
            if (m_scheduler == null)
            {
                m_log.Error("LLSceneFactory requires an IScheduler");
                return false;
            }

            m_scenes = new Dictionary<UUID, IScene>();

            m_renderer = simian.GetAppModule<ISceneRenderer>();
            m_gridClient = simian.GetAppModule<IGridClient>();

            string[] sceneFiles = null;

            try { sceneFiles = Directory.GetFiles(SOURCE_PATH, "*.ini", SearchOption.AllDirectories); }
            catch (DirectoryNotFoundException)
            {
                m_log.Warn(Path.GetFullPath(SOURCE_PATH) + " not found, cannot load scene definitions");
                return false;
            }

            for (int i = 0; i < sceneFiles.Length; i++)
            {
                // Create the config source for this region by merging the app config and the region config
                IConfigSource configSource = simian.GetConfigCopy();
                IniConfigSource regionConfigSource = new IniConfigSource(sceneFiles[i]);
                configSource.Merge(regionConfigSource);

                IConfig config = configSource.Configs["LindenRegion"];

                if (config != null)
                {
                    UUID id;
                    UUID.TryParse(config.GetString("ID"), out id);

                    string name = config.GetString("Name");

                    uint locationX = 0, locationY = 0;
                    string[] locationParts = config.GetString("Location").Trim().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    if (locationParts.Length != 2 || !UInt32.TryParse(locationParts[0], out locationX) || !UInt32.TryParse(locationParts[1], out locationY))
                    {
                        m_log.Warn("Missing or invalid Location for " + name + " region");
                    }
                    Vector3d regionPosition = new Vector3d(locationX * (uint)REGION_SIZE, locationY * (uint)REGION_SIZE, 0.0d);

                    Scene scene = new Scene(id, name, regionPosition, new Vector3d(256.0, 256.0, 4096.0), simian, configSource);
                    m_log.Info("Starting scene " + scene.Name + " (" + scene.ID + ")");
                    scene.Start();

                    m_scenes[scene.ID] = scene;

                    // Create a map tile for this scene
                    m_scheduler.FireAndForget(o => CreateMapTile((IScene)o), scene);
                }
                else
                {
                    m_log.Warn("No [LindenRegion] config section found in " + sceneFiles[i] + ", skipping");
                }
            }

            // Create the array
            m_scenesArray = new IScene[m_scenes.Count];
            int j = 0;
            foreach (IScene scene in m_scenes.Values)
                m_scenesArray[j++] = scene;

            // Fire the OnSceneStart callback for each scene we started
            SceneStartCallback callback = OnSceneStart;
            if (callback != null)
            {
                for (int i = 0; i < m_scenesArray.Length; i++)
                {
                    callback(m_scenesArray[i]);
                }
            }

            return true;
        }
Пример #13
0
        public bool Start(Simian simian)
        {
            m_simian = simian;
            m_httpServer = simian.GetAppModule<IHttpServer>();
            m_assetClient = simian.GetAppModule<IAssetClient>();

            m_sceneFactory = simian.GetAppModule<ISceneFactory>();
            if (m_sceneFactory != null)
            {
                m_sceneFactory.OnSceneStart += SceneStartHandler;
                m_sceneFactory.OnSceneStop += SceneStopHandler;
            }

            IConfigSource source = simian.Config;

            IConfig config = source.Configs["SimianGrid"];
            if (config != null)
                m_serverUrl = config.GetString("GridService", null);

            if (String.IsNullOrEmpty(m_serverUrl))
            {
                m_log.Error("[SimianGrid] config section is missing the GridService URL");
                return false;
            }

            return true;
        }
Пример #14
0
        public bool Start(Simian simian)
        {
            m_assetClient = simian.GetAppModule<IAssetClient>();

            return true;
        }