コード例 #1
0
        private void Init(string[] args, ProxyConfig proxyConfig)
        {
            //bool externalPlugin = false;
            this.args = args;

            if (proxyConfig == null)
            {
                proxyConfig = new ProxyConfig("GridProxy", "Austin Jennings / Andrew Ortman", args, true);
            }
            proxy = new Proxy(proxyConfig);

            // add delegates for login
            proxy.AddLoginRequestDelegate(new XmlRpcRequestDelegate(LoginRequest));
            proxy.AddLoginResponseDelegate(new XmlRpcResponseDelegate(LoginResponse));

            // add a delegate for outgoing chat
            proxy.AddDelegate(PacketType.ChatFromViewer, Direction.Outgoing, new PacketDelegate(ChatFromViewerOut));

            //  handle command line arguments
            foreach (string arg in args)
            {
                if (arg == "--log-login")
                {
                    logLogin = true;
                }
                else if (arg.Substring(0, 2) == "--")
                {
                    int ipos = arg.IndexOf("=");
                    if (ipos != -1)
                    {
                        string sw  = arg.Substring(0, ipos);
                        string val = arg.Substring(ipos + 1);

                        Logger.Log("arg '" + sw + "' val '" + val + "'", Helpers.LogLevel.Debug);

                        if (sw == "--load")
                        {
                            //externalPlugin = true;
                            LoadPlugin(val);
                        }
                    }
                }
            }

            commandDelegates["/load"] = new CommandDelegate(CmdLoad);
        }
コード例 #2
0
 private void CmdLoad(string[] words)
 {
     if (words.Length != 2)
     {
         SayToUser("Usage: /load <plugin name>");
     }
     else
     {
         try
         {
             LoadPlugin(words[1]);
         }
         catch (Exception e)
         {
             Logger.Log("LoadPlugin exception", Helpers.LogLevel.Error, e);
         }
     }
 }
コード例 #3
0
        public void LoadPlugin(string name)
        {
            Assembly assembly = Assembly.LoadFile(Path.GetFullPath(name));

            foreach (Type t in assembly.GetTypes())
            {
                try
                {
                    if (t.IsSubclassOf(typeof(ProxyPlugin)))
                    {
                        ConstructorInfo info   = t.GetConstructor(new Type[] { typeof(ProxyFrame) });
                        ProxyPlugin     plugin = (ProxyPlugin)info.Invoke(new object[] { this });
                        plugin.Init();
                    }
                }
                catch (Exception e)
                {
                    Logger.Log("LoadPlugin exception", Helpers.LogLevel.Error, e);
                }
            }
        }
コード例 #4
0
 protected void StartPoxy()
 {
     AppendLog("Starting proxy..." + Environment.NewLine);
     try
     {
         proxy = new ProxyManager(txtPort.Text, cbListen.ActiveText, cbLoginURL.ActiveText);
         proxy.Start();
         btnLoadPlugin.Sensitive = true;
         ApplyProxyFilters();
     }
     catch (Exception ex)
     {
         Logger.Log("Failed to start proxy: " + ex.Message, OpenMetaverse.Helpers.LogLevel.Error);
         try
         {
             proxy.Stop();
         }
         catch { }
         btnStart.Label = "Start Proxy";
         proxy          = null;
     }
 }