Well, I'd recommend you to learn how http upgrade works and to learn details of websocket protocol. Without knowing this it'd be very hard for you to continue.
Cheers, Fedor. On Sat, Jan 5, 2013 at 10:56 PM, kyogron <[email protected]> wrote: > Thanks for the quick response :) > > var http = require('http'); > > var server = http.createServer(); > > server.on('request', function(req, res) { > res.setHeader('Content-Type', 'text/plain'); > res.end('hello world'); > }); > > server.on('upgrade', function(req, socket, head) { > console.log('upgrading'); > socket.write('upgraded'); > socket.on('data', function() { > console.log(arguments); > }); > }); > > server.listen(3000); > > in the chrome console: > var ws = new WebSocket('ws://localhost:3000); > ws.onopen = function() { > ws.send('hello'); > }; > > > Except console.log('upgrading') there is no output at all. > > > The browser waits on a http response (it shows me pending and no response > available). > The question is just how I could send one without a request obj supplied > to the callback? > > Am Samstag, 5. Januar 2013 19:15:38 UTC+1 schrieb Fedor Indutny: >> >> As you can see, 'upgrade' event listener receives `socket` object. >> >> Try doing: socket.write('something'). >> >> Cheers, >> Fedor. >> >> >> On Sat, Jan 5, 2013 at 10:11 PM, kyogron <[email protected]> wrote: >> >>> Hi, >>> >>> I want to implement a WebSocket server. >>> >>> I am currently at the beginnings handling the HTTP Protocol upgrade >>> handshake. >>> >>> The handshake requires a response for security reasons unfortunately the >>> "upgrade" event does not provide any response object or at least I cannot >>> find one. >>> >>> Is there an other way to response as a listener of the Event: >>> 'upgrade'<http://nodejs.org/api/http.html#http_event_upgrade> >>> ? >>> >>> Regards >>> >>> -- >>> Job Board: http://jobs.nodejs.org/ >>> Posting guidelines: https://github.com/joyent/**node/wiki/Mailing-List-* >>> *Posting-Guidelines<https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines> >>> You received this message because you are subscribed to the Google >>> Groups "nodejs" group. >>> To post to this group, send email to [email protected] >>> >>> To unsubscribe from this group, send email to >>> nodejs+un...@**googlegroups.com >>> >>> For more options, visit this group at >>> http://groups.google.com/**group/nodejs?hl=en?hl=en<http://groups.google.com/group/nodejs?hl=en?hl=en> >>> >> >> -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
