Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
plugin tutorials
Results 1 to 2 of 2

Thread: plugin tutorials

  1. #1
    Senior Member
    Join Date
    Jun 2007
    Posts
    247

    plugin tutorials

    Here you will find a series of tutorials for writing plugins for nonameproxy.

    These tutorials are structured in two parts. First there will be some background information posted in this forum. The second part will be a tutorial plugin which will be committed to the svn. The tutorial plugins will be heavily commented. you can check out the svn here

    http://code.google.com/p/nonameproxy/source/checkout

    I test all the plugins with my windows build, so you can be 99% sure they will work.

    If you have any questions, please ask in the nonameproxy forum, this thread will be locked, unless im working on it. If its unlocked and you post in here, your post will be deleted

  2. #2
    Senior Member
    Join Date
    Jun 2007
    Posts
    247

    plugin tutorials

    Lesson 1: hello world

    Welcome to the first tutorial for writing plugins for nonameproxy. In this tutorial we I will cover basic theory, and then demonstrate how to write a hello world plugin.

    Plugins are very simple, all they are are shared libraries which are loaded at runtime. The biggest advantage to plugins is that they can also be unloaded at runtime, meaning if you want to change a plugin you dont have to restart the proxy. The other advantage is that plugins are modular, and therefore very easy to maintain (assuming I dont screw you over by changing the interface). They can also access the full power of nonameproxy (or will be able to eventually, the proxy itself is currently incomplete) which means that you can see results, very quickly whilst only writing a small amount of code.

    In order for the proxy to load your plugin, it must have 3 functions, this is all that is required. The first function is load (). load will be called when your plugin is first loaded into the proxy and gives you a chance to initialize any data your plugin may need to operate. load is passed two variables, the first is your plugin id, and the second is a pointer to the proxy "client". The client is at the core of the proxy and is where the plugin can access the proxy's functionality. In order to access the clients functionality however, you must tell it which plugin you are using your plugin id. This gives you unprecedented control over the proxy, but also gives you the ability to be evil. For example you could tell the proxy that you have a different plugin id, and then another plugin will be affected by your actions. If you do this, you are evil, and you will be punished.

    The second function is unload (), which is called when the proxy unloads your plugin. In this function you have the ability to clean up any data you have made in your plugin.

    The final function is name (), which returns a reference to a string containing your plugins name. If you dont know what a reference is, you should really go read up on that else where, but in a nut shell you dont return the actual string, but something telling the proxy where to find the string. This means the string must be declared somewhere outside of your function where it wont be destroyed. The name of your plugin is important because it is what identifies your plugin within the proxy's internal inter-plugin communication system. The proxy also want let you load two plugins with the same name.

    In the svn, there is now a folder called tutorial1 which is heavily commented. If you check out the svn, you can compile and use play with this very simple plugin.

    Some notes on compiling:
    I use command line utilities to do my work. Included in the file is a Makefile. If you have make installed on your computer, you can edit this file by changing the windows CXX, AR, etc variables to the paths of your g++, ar ect and compile by simple typing make.
    Because this is such a simple project, your second option is to compile the project on the command line alone using.
    g++ -Wall -I..\.. -DBUILD_DLL -shared -o tutorial1.dll tutorial1.cpp ..\..\nonameproxy.dll
    where g++ is the path to your g++.exe.
    the -I..\.. is needed to include files in the directory where the core proxy's source code is located. The ..\..\nonameproxy.dll is needed to tell the the compiler where to find nonameproxy.dll where the core code is compiled.
    The third option is to set up a dev-cpp or code::blocks project to compile the entire source, including the core and plugins. If you do this, let me know and ill add your project file to the svn.

    Thats it for the first tutorial.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •