Hi Greg... i would like to know how are we supposed to open the
Channels in the current state of the server and SDK that are served
from a backend, i'm currently opening the channel from within the
backend and passing the token to my frontend but to no avail, here's a
little sample code:
*** On the frontend:
cmd = Command.login(id, password)
campaign= "campanamsl"
# Enqueue on the backend command list
task_name = "backend_%s_counter" % (campaign)
dct = cmd.to_dictionary()
idx = int(memcache.incr(task_name,
initial_value=0))
key_name = "%s_cmd_%i" % (task_name, idx)
memcache.set(key_name, dct, time=1000)
# Wait the token from the backend
channel = None
num = 0
while (channel is None) and (num < 10): # This (1)
loop will unlock when the backend replies with the usr info
channel = memcache.get(key_name+"_resp")
num += 1
if channel is None:
time.sleep(0.01)
if channel is not None:
ent = User(id)
memcache.set(id, ent)
sess['usr'] = ent
sess.save()
self.response.out.write(simplejson.dumps({"sta": ":-)", "chtok":
channel}))
*** On the backend:
cnt = int(memcache.get(self.counter_name)) # counter_name is
the same as task_name in the frontend
if cnt is not None:
while (cnt > self.cmds_count):
self.cmds_count += 1
cmd = memcache.get("%s_cmd_%i" % (self.counter_name,
self.cmds_count))
if (cmd is not None):
command= Command()
command.from_dictionary(cmd)
ent = None
if command.mapa is None:
map = self.campaign.pos['map']
else:
map = int(command.map)
ents = self.ents_per_map[map]
try:
ent = ents[command.origin]
except KeyError:
# Probably a SPAWN or LOGIN
if command.tipo == Command.SPAWN:
ent = memcache.get(command.origin)
elif command.tipo == Command.LOGIN:
# Not verifying user password yet
chan =
channel.create_channel(command.origin)
memcache.set("%s_cmd_%i_resp" %
(self.counter_name, self.cmds_count), chan, time=1000) # This unblock
the (1) loop in the frontend
***
The client side channel gets the token correctly, however nothing is
received on the onmessage event of my channel handler. After a while
the backend instance begins throwing "ProtocolBufferDecodeError:
corrupted" on line 481 on google\net\proto\ProtocolBuffer.py :-(
Please, tell me what i'm doing wrong here (if you can figure it out,
of course)
On 13 mayo, 14:16, "Greg Darke (Google)" <
darke+goo...@google.com>
wrote:
> This sounds like a excellent use of backends.
>
> I believe that there is currently a limitation that a channel created
> in a frontend (ie, your default version) is not able to be used to
> send messages from a backend.
>
> As noted in the Google IO talk, we are currently working on removing
> this restriction. For the moment, you could work around this
> limitation by creating the channel in the backend that you want to
> send messages from, then pass it back to the frontend/user.
>