3

I'm working on a HTML5 collaborative canvas drawing tool on GAE. Essentially people draw, send their coordinates and their motion to GAE through channel API and then other people receive the updates.

As required by the GAE documentation, I have a function in my javascript code to collect messages received from the server:

socket.onmessage= function (message) {
    var s=message.data;
    //Extract X,Y,motion out of s and Draw(x,y,motion)
};

However, the message data I'm sending are actually x and y coordinates and a string of either ("start"/"drag") in the form of:

x=505.0000457763672&y=111.66667175292969&type=start

I actually have no idea about any of the variables or features in this 'message' class and I wouldn't know to use 'message.data' if I didn't see it in someone else's source code - is this actually documented anywhere? I'd like to be able to use the substring features to effectively extract the 3 values but they don't seem to work with message.data.

Any idea if there are detailed documentations on the full member functions/classes/variables documentation on the message class?

Any input is much appreciated!

Euky Chan
  • 33
  • 2

1 Answers1

1

I wouldn't say it's documented WELL, but it is documented in the channels API docs: https://developers.google.com/appengine/docs/python/channel/javascript

It specifically does say the message object has a parameter called 'data'.

You should be able to use javascript substring features just fine, but unless you show your code, no one will be able to help you with that.

dragonx
  • 14,963
  • 27
  • 44
  • Thank you! Eventually got the substring functions to work, but the end result of a real-time drawing interface on channel API isn't too ideal unfortunately – Euky Chan Dec 11 '12 at 14:52
  • @EukyChan good you got it working. Just curious, what are the problems you're running into? Channel API too slow or loses messages? – dragonx Dec 11 '12 at 15:52
  • Thanks - I was wanting to implement a (naive, perhaps) collaborative real time drawing board where every point drawn on the canvas pushes a request through Channel API to the other users. the resulting implementation sent around 20 POST requests for a single line so it was highly ineffective, ended up doing an implementation with individual strokes (e.g. you send the whole stroke on mouse release as a single shape) – Euky Chan Feb 07 '13 at 12:35