Hi,
-- I'm going through some Node JS examples using Amber for creating server side code and I've come across a problem. Here is my chat server code: NodeServer>>chatServer | net server sockets | net := require value: 'net'. sockets := Array new. server := net createServer: [:socket | sockets add: socket. socket on: 'data' do: [:data | (sockets reject: [:each | each == socket]) do: [:eachSocket | eachSocket write: data ]]. socket on: 'close' do: [ sockets remove: socket ifAbsent: [ Transcript show: 'Couldn''t disconnect'; cr]]. socket write: 'Connected to Node Chat Server']. server listen: 8000. Transcript show: 'Server started on 8000'; cr. The server blows up with an error whenever I send data to it or disconnect. The actual error that comes back from Node isn't really very descriptive but I include it here for completeness: TypeError: Cannot call method '_handleError_' of undefined at handleError (/Users/bower/Dropbox/Apps/Amber/amber-master/NodeHelloWorld.js:1226:30) at Smalltalk.RuntimeBrik.st.withContext (/Users/bower/Dropbox/Apps/Amber/amber-master/NodeHelloWorld.js:1170:5) at Socket.<anonymous> (/Users/bower/Dropbox/Apps/Amber/amber-master/NodeHelloWorld.js:20663:18) at Socket.EventEmitter.emit (events.js:95:17) at Socket.<anonymous> (_stream_readable.js:746:14) at Socket.EventEmitter.emit (events.js:92:17) at emitReadable_ (_stream_readable.js:408:10) at emitReadable (_stream_readable.js:404:5) at readableAddChunk (_stream_readable.js:165:9) at Socket.Readable.push (_stream_readable.js:127:10) Now, I'm pretty sure that the error in both cases is caused by the lack of equality and identity methods in ProtoObject. So what I did was to move #= and #== up into ProtoObject and this prevent the code blowing up but it still doesn't work because it seems the incoming socket is never matched with the one stored in the collection. I tried adding: Transcript show: socket==socket. And this always shows false. I also tried implementing a #=== method in ProtoObject to call the native JS operator: === anObject <return self === anObject> But if I again try: Transcript show: socket===socket. This also answers false. Any ideas what can be going on here? Best regards You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/groups/opt_out. |
master already has ProtoObject = and ==.
https://github.com/amber-smalltalk/amber/issues/792 Herby bowerandy wrote: > Hi, > > I'm going through some Node JS examples using Amber for creating > server side code and I've come across a problem. > > Here is my chat server code: > > NodeServer>>chatServer > | net server sockets | > net := require value: 'net'. > sockets := Array new. > server := net createServer: [:socket | > sockets add: socket. > socket on: 'data' do: [:data | > (sockets reject: [:each | each == socket]) do: [:eachSocket | > eachSocket write: data ]]. > socket on: 'close' do: [ > sockets remove: socket ifAbsent: [ > Transcript show: 'Couldn''t disconnect'; cr]]. > socket write: 'Connected to Node Chat Server']. > server listen: 8000. > Transcript show: 'Server started on 8000'; cr. > > The server blows up with an error whenever I send data to it or > disconnect. The actual error that comes back from Node isn't really > very descriptive but I include it her > > TypeError: Cannot call method '_handleError_' of undefined > > at handleError > (/Users/bower/Dropbox/Apps/Amber/amber-master/NodeHelloWorld.js:1226:30) > > at Smalltalk.RuntimeBrik.st.withContext > (/Users/bower/Dropbox/Apps/Amber/amber-master/NodeHelloWorld.js:1170:5) > > at Socket.<anonymous> > (/Users/bower/Dropbox/Apps/Amber/amber-master/NodeHelloWorld.js:20663:18) > > at Socket.EventEmitter.emit (events.js:95:17) > > at Socket.<anonymous> (_stream_readable.js:746:14) > > at Socket.EventEmitter.emit (events.js:92:17) > > at emitReadable_ (_stream_readable.js:408:10) > > at emitReadable (_stream_readable.js:404:5) > > at readableAddChunk (_stream_readable.js:165:9) > > at Socket.Readable.push (_stream_readable.js:127:10) > > > Now, I'm pretty sure that the error in both cases is caused by the > lack of equality and identity methods in ProtoObject. So what I did > was to move #= and #== up into ProtoObject and this prevent the code > blowing u > socket is never matched with the one stored in the collection. I tried > adding: > > > Transcript show: socket==socket. > > > And this always shows false. I also tried implementing a #=== method > in ProtoObject to call the native JS operator: > > > === anObject > > <return self === anObject> > > > But if I again try: > > > Transcript show: socket===socket. > > > This also answers false. > > > Any ideas what can be going on here? > > > Best regards > > > > -- > You received this message because you are subscribed to the Google > Groups "amber-lang" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to [hidden email]. > For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/groups/opt_out. |
Hi Herby,
-- Pulling the latest master fixes the problem, thanks. Best regards On Friday, January 17, 2014 10:13:17 PM UTC, Herby wrote: master already has ProtoObject = and ==. You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/groups/opt_out. |
Free forum by Nabble | Edit this page |