eudemonia-research / spore

Spore is a simple peer-to-peer library for Python.
6 stars 5 forks source link

Problem with the chat example #7

Closed devnix closed 10 years ago

devnix commented 10 years ago

The beacon example it's also outdated, I changed .start() for .run() and called both process in threads, but it doesn't work.

Right now I'm working on launch the chat example and understand it. I've launched the first client with ports 5000 and 5000. When I try to send a message, I get this:

Traceback (most recent call last):
  File "./chat.py", line 53, in <module>
    me.broadcast('chat', bytes([message.encode('utf-8'),nick.encode('utf-8'),uid.encode('utf-8')]))
TypeError: 'bytes' object cannot be interpreted as an integer
devnix commented 10 years ago

That

me.broadcast('chat', bytes([

bytes was added by me because the original line throws this error:

Traceback (most recent call last):
  File "./chat.py", line 53, in <module>
    me.broadcast('chat', [message.encode('utf-8'),nick.encode('utf-8'),uid.encode('utf-8')])
  File "/home/devnix/dev/p2pTest/src/local/lib/python3.3/site-packages/spore/__init__.py", line 122, in broadcast
    protocol.send(method, data)
  File "/home/devnix/dev/p2pTest/src/local/lib/python3.3/site-packages/spore/__init__.py", line 31, in send
    message = Message.make(method=method, payload=payload).serialize()
  File "/home/devnix/dev/p2pTest/src/local/lib/python3.3/site-packages/encodium/__init__.py", line 196, in make
    return cls().make(*args, **kwargs)
  File "/home/devnix/dev/p2pTest/src/local/lib/python3.3/site-packages/encodium/__init__.py", line 106, in make
    ret = self.type(*args, **kwargs)
  File "/home/devnix/dev/p2pTest/src/local/lib/python3.3/site-packages/encodium/__init__.py", line 52, in __init__
    setattr(inner_self, key, value)
  File "/home/devnix/dev/p2pTest/src/local/lib/python3.3/site-packages/encodium/__init__.py", line 89, in __setattr__
    field.check_type(value)
  File "/home/devnix/dev/p2pTest/src/local/lib/python3.3/site-packages/encodium/__init__.py", line 136, in check_type
    raise ValidationError("is of type " + instance_type + ", expected " + expected_type)
encodium.ValidationError: payload is of type list, expected bytes
XertroV commented 10 years ago

Thanks DevNIX, I've updated the examples and they should work now.

devnix commented 10 years ago

Thanks, XertroV :D I'll start playing with this.