From: Tom Sawyer Date: 2002-09-08T22:52:11+09:00 Subject: ONI 2 --=-tIosL4Z7D3mlJzxNz5nz Content-Type: text/plain Content-Transfer-Encoding: 7bit i've been workng on ONI (Object Network Interface) this evening. i had started by trying to change over to HTTP using WEBrick, instead of straight TCP. but had problems there and went back to TCP. but an interesting development has arisen in the course this evenings work and i'm wondering what others might think of it. while initially the intention of ONI was to put together an RPC system like SOAP and XML-RPC, but using YAML instead of XML, it has now become something a little different and i'm not sure what to make of it really. i've done what appears to be some very unique things. (i'm acutally half surprised that it even works) here's a list of the "unique" things that i have done: 1. i converted ONI into a Peer-to-Peer-like system instead of a just a pat Client-Server system. (like DRb?) 2. you can request any new class of object that the remote eviornment has, simply by saying ObjClass.oni_new. in otherwords, unlike DRb, you're not limited to serving just a single object. i achieve this by dynamically defining an "empty shell" class for every class the remote machine has, but the local (client) machine does not. 3. instead of serializing an object and passing it through the network, i've created an object pool to store the real object and in its place pass a remote-reference-object which points to it. 4. this remote reference object is a "bare object". i literally use #undef_method on every method possible. then missing_method is used to call to the remote machine and pick up the real object in the pool on which the method is then called. the return of a remote method call is the only thing ever serialized and passed back. i've attached the examples of the "server" and "client" for you to take a look at, and i'll have the code up on my site in a while. let you know when. like i said, ONI's turned into a very strange beast, and i'm not sure yet what to make of it. have i achived anything new really? or is all this already done in variant ways? -- tom sawyer, aka transami transami@transami.net --=-tIosL4Z7D3mlJzxNz5nz Content-Disposition: attachment; filename=oniserver.rb Content-Transfer-Encoding: quoted-printable Content-Type: text/x-ruby; name=oniserver.rb; charset=ANSI_X3.4-1968 # ONI - Object Network Interface # Copyright (c) 2002 Thomas Sawyer, LGPL # # Example: ONI Server # ONI is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published = by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # ONI is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with ONI; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA require 'oni/oni' class Object1 =20 def initialize end =20 def call_me(*args) return "Hi, from Object 1. You passed: #{args.join(', ')}" end =20 end class Object2 =20 def initialize end =20 def call_me(*args) return "Hi, from Object 2. You passed: #{args.join(', ')}" end =20 end ONI::Peer.setup('192.168.0.167', '8080') ONI::Peer.go.join --=-tIosL4Z7D3mlJzxNz5nz Content-Disposition: attachment; filename=oniclient.rb Content-Transfer-Encoding: quoted-printable Content-Type: text/x-ruby; name=oniclient.rb; charset=ANSI_X3.4-1968 # ONI - Object Network Interface # Copyright (c) 2002 Thomas Sawyer, LGPL # # Example: ONI Client # ONI is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published = by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # ONI is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with ONI; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA require 'oni/oni' ONI::Peer.setup('192.168.0.167', '8081') ONI::Peer.go # subscribe to service ONI::Peer.subscribe('192.168.0.167:8080', 'guest', '') # talk to object 1 obj1 =3D Object1.oni_new('192.168.0.167:8080') puts obj1.call_me('please', 'pretty please') # talk to object 2 obj2 =3D Object2.oni_new('192.168.0.167:8080') puts obj2.call_me('thanks', 'much thanks') # unsubscribe from service #puts oni_unsubscribe --=-tIosL4Z7D3mlJzxNz5nz--