Here's a zip of the real program, if you want to see absolutely
everything in context:
http://marky1991.dyndns.org/archivos/CRABcon.zip
(The client is defined in client.py, server in server.py)
Here's my debugger output (This may not be 100% what the debugger
outputs. It's intermingled with output from some of my print
statements. I tried to remove all of mine.)
(It crashes at the end because the client tries to send a "Make map
event" to the server, which ends up getting put in its own event
queue. The client doesn't have a make_map method, causing it to
crash.):
http://marky1991.dyndns.org/archivos/debug.txt
Here's the snippet from the client that I'm trying to write so as to
only send to the server:
def send(self, event):
if event:
#This just turns objects into strings.
sent = util.bytify(event) + constants.message_delimiter
sent= sent.encode("utf-8")
logger.print("Client Sent: " + sent.decode("utf-8"),
subject="CLIENT")
logger.print("Client is sending a message of size: ",
sys.getsizeof(sent), subject="CLIENT")
#I thought TCPServer objects by default listen to a server
channel, so
#I would think this would only be heard by the server.
self.fire(circuit.Write(sent), "server")
And here's the server's write handler:
@handler("write")
def read(self, source, data):
logger.print("The server recieved a response: ", data,
subject="SERVER")
for line in
data.decode("utf-8").split(constants.message_delimiter):
if line:
event = util.debytify(line)
print(line, event, "HERE")
event_tuple = event.handle(self)
if event_tuple:
print(event_tuple, "tup")
self.send(None, event_tuple, socket=source)
logger.print("Server Received: {}".format(responses),
subject="SERVER")
A simple example showing how to only send events to the server would
be great. Thinking about it now, I have the client listening to every
channel, so I can see how it would hear it. But I didn't think it
would notice it because it doesn't have a server channel. I would have
thought I could have just done it by specifying target="server" or
something similar, but the target parameter was removed from fire in
circuits 2 as far as I can tell from reading the source.
RE the purpose of the go method: I have to do some other startup stuff
that most conveniently goes there. The example was too simple, making
it look pointless.
Sorry if I'm being an unhelpful help_asker_forer.