Sending class instances over a socket
When you send an instance of a class over a socket, it sends the object with one of its attributes telling you what class it's an instance of. This attribute has a constructor which has a object of the global scope
for example:
Point = class
constructor=function(x,y)
this.x=x
this.y=y
end
end
p = new Point(0,0)
/*
object
class=Point
x=0
y=0
*/
connection.send(p) //doesn't send because...
p.class.constructor.object==global //which obviously contains Point
I can think of three solutions:
- a: remove the class attribute before sending if sending a class instance
- b: find a way to specify the class (which sounds the hardest)
- c: remove the "object" attribute from the constructor when sending a class instance