Hi all,
I am finding very little documentation/examples about 3.0.7's services, and
I struggle even to do the simple things (which well, should work, but maybe
my work's network blocks the ports?)...
So *very simple*... I want a working client and server... then later clients
and server. (but that's way later).
So server.py:
> import rpyc
> class ListenServer(rpyc.Service):
def on_connect(self):
print "connected!"
> def on_disconnect(self):
print "disconnected"
> def exposed_move(self, ojb, x=None, y=None):
print "move called"
> def exposed_talk(self, text=None):
print text
> def main():
s = rpyc.utils.server.ThreadedServer(ListenServer).start() #this code I
> got from http://www.ibm.com/developerworks/linux/library/l-rpyc/
pass
> if __name__ == '__main__':
main()
Right, so a *very* simple server, exposing move, which at this stage does
nothing, and talk, which will print (on the server I assume?!) the text that
the client sent.
Client:
> import rpyc
def main():
c = rpyc.connect("localhost",45000) # this gives an error,
> which says: No connection could be made because the target machine actively
> refused it (work firewall?)
test = c.root.exposed_talk("Hello World!") # do I go "exposed_talk"
> or just "talk?"
pass
> if __name__ == '__main__':
main()
Connect, and run the exposed function. (Is this done right?) No idea!
Ok so this is not working at the moment. But where I want to be is (and if
someone can show me how far I am from proof of concept I'd *really
appreciate it*):
I have this sample code, written with *visual *(http://vpython.org)... I'd
like a server which will, update any new "cards" that is added with
ctrl-click to each of the clients (of which there may be an arbitrary
amount), and any move that a client makes to a "card" to be updated to all
of the clients.
3dtest.py:
> from visual import *
> scene.userspin = 1
grey = (0.2, 0.2, 0.25)
> scene.width = 800
scene.height = 400
scene.center = (0,1,2)
scene.title = "rpyc testing the 3d moving of objects!"
wcube = 100
> cube = box(length=wcube, width=wcube, height=wcube/100, color=grey)
card = box(pos=(0,1,0),length=wcube/10, width=wcube/10, height=wcube/20,
> color=(1,1,1))
dragobj = None
objects = []
objects.append(card)
> while True:
rate(50)
if scene.mouse.events:
m = scene.mouse.getevent()
print m.click
if m.drop == "left":
dragobj = None
continue
elif m.click == "left" and m.ctrl:
objects.append(box(pos=(0,1,0),length=wcube/10, width=wcube/10,
> height=wcube/20, color=(1,1,1)))
* # rpycconnection.root.exposed_createobj(newcard) ???*
elif m.drag == "left":
for index in range(len(objects)):
s = objects[index]
if m.pick is s:
pos = m.project(normal=(1,0,0))
dragobj = s
newpos = scene.mouse.project(normal=(0,1,0))
if dragobj and (newpos != pos):
pos = newpos
dragobj.pos = vector(pos)
*# rpycconnection.root.exposed_updateobj(dragobj, vector(pos)) ???*
This is maybe a bit of a too complex thing to just throw at the mailling
list, but I'd love to see how the client would look and update, to start to
wrap my head around how I can implement my bigger vision.
Regards,
-Reenen
--
o__
,_.>/ _
(_)_\(_)_______
...speed is good
_______________
I believe five out of four people have a problem with fractions.