コード例 #1
0
ファイル: RPCHandler.cs プロジェクト: velus/Async-Sim-Testing
        public void Start(IConfigSource config, IRegistryCore registry)
        {
            if (config.Configs["Currency"] == null ||
                config.Configs["Currency"].GetString("Module", "") != "SimpleCurrency")
                return;
            if (!config.Configs["Currency"].GetBoolean("RunServer", false))
                return;

            m_connector = DataManager.RequestPlugin<ISimpleCurrencyConnector>() as SimpleCurrencyConnector;

            if (m_connector.GetConfig().ClientPort == 0 && MainServer.Instance == null)
                return;
            IHttpServer server =
                registry.RequestModuleInterface<ISimulationBase>()
                        .GetHttpServer((uint) m_connector.GetConfig().ClientPort);
            server.AddXmlRPCHandler("getCurrencyQuote", QuoteFunc);
            server.AddXmlRPCHandler("buyCurrency", BuyFunc);
            server.AddXmlRPCHandler("preflightBuyLandPrep", PreflightBuyLandPrepFunc);
            server.AddXmlRPCHandler("buyLandPrep", LandBuyFunc);
            server.AddXmlRPCHandler("getBalance", GetbalanceFunc);
            server.AddXmlRPCHandler("/currency.php", GetbalanceFunc);
            server.AddXmlRPCHandler("/landtool.php", GetbalanceFunc);

            m_syncMessagePoster = registry.RequestModuleInterface<ISyncMessagePosterService>();
            m_agentInfoService = registry.RequestModuleInterface<IAgentInfoService>();
        }
コード例 #2
0
        public XmlRpcResponse LandBuyFunc(XmlRpcRequest request, IPEndPoint ep)
        {
            Hashtable requestData = (Hashtable)request.Params[0];

            bool success = false;

            if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy") &&
                m_connector.GetConfig().CanBuyCurrencyInworld)
            {
                UUID agentId;
                if (UUID.TryParse((string)requestData["agentId"], out agentId))
                {
                    uint amountBuying = uint.Parse(requestData["currencyBuy"].ToString());
                    m_connector.UserCurrencyTransfer(agentId, UUID.Zero, amountBuying,
                                                     "Inworld purchase", TransactionType.SystemGenerated, UUID.Zero);
                    success = true;
                }
            }
            XmlRpcResponse returnval  = new XmlRpcResponse();
            Hashtable      returnresp = new Hashtable {
                { "success", success }
            };

            returnval.Value = returnresp;
            return(returnval);
        }
コード例 #3
0
        public void Start(IConfigSource config, IRegistryCore registry)
        {
            if (config.Configs["Currency"] == null ||
                config.Configs["Currency"].GetString("Module", "") != "SimpleCurrency")
            {
                return;
            }
            if (!config.Configs["Currency"].GetBoolean("RunServer", false))
            {
                return;
            }

            m_connector = DataManager.RequestPlugin <ISimpleCurrencyConnector>() as SimpleCurrencyConnector;

            if (m_connector.GetConfig().ClientPort == 0 && MainServer.Instance == null)
            {
                return;
            }
            IHttpServer server =
                registry.RequestModuleInterface <ISimulationBase>()
                .GetHttpServer((uint)m_connector.GetConfig().ClientPort);

            server.AddXmlRPCHandler("getCurrencyQuote", QuoteFunc);
            server.AddXmlRPCHandler("buyCurrency", BuyFunc);
            server.AddXmlRPCHandler("preflightBuyLandPrep", PreflightBuyLandPrepFunc);
            server.AddXmlRPCHandler("buyLandPrep", LandBuyFunc);
            server.AddXmlRPCHandler("getBalance", GetbalanceFunc);
            server.AddXmlRPCHandler("/currency.php", GetbalanceFunc);
            server.AddXmlRPCHandler("/landtool.php", GetbalanceFunc);

            m_syncMessagePoster = registry.RequestModuleInterface <ISyncMessagePosterService>();
            m_agentInfoService  = registry.RequestModuleInterface <IAgentInfoService>();
        }
コード例 #4
0
        public void FinishedStartup()
        {
            if (m_registry == null)
            {
                return;
            }
            ISceneManager manager = m_registry.RequestModuleInterface <ISceneManager>();

            if (manager != null)
            {
                manager.OnAddedScene += (scene) =>
                {
                    m_scenes.Add(scene);
                    scene.EventManager.OnNewClient       += OnNewClient;
                    scene.EventManager.OnClosingClient   += OnClosingClient;
                    scene.EventManager.OnMakeRootAgent   += OnMakeRootAgent;
                    scene.EventManager.OnValidateBuyLand += EventManager_OnValidateBuyLand;
                    scene.RegisterModuleInterface <IMoneyModule>(this);
                };
                manager.OnCloseScene += (scene) =>
                {
                    scene.EventManager.OnNewClient       -= OnNewClient;
                    scene.EventManager.OnClosingClient   -= OnClosingClient;
                    scene.EventManager.OnMakeRootAgent   -= OnMakeRootAgent;
                    scene.EventManager.OnValidateBuyLand -= EventManager_OnValidateBuyLand;
                    scene.RegisterModuleInterface <IMoneyModule>(this);
                    m_scenes.Remove(scene);
                };
            }

            if (!m_connector.DoRemoteCalls)
            {
                if ((m_connector.GetConfig().GiveStipends) && (m_connector.GetConfig().Stipend > 0))
                {
                    new GiveStipends(m_connector.GetConfig(), m_registry, m_connector);
                }
            }
        }