Monday 22 October 2012

Testing sockets

Since latest version of the application you can test socket messaging as well. It is simple implementation of the web socket API.

For server implementation you can use for example the ws module for node.js.

Below is sample server side code:

var WebSocketServer = require('ws').Server
  , wss = new WebSocketServer({port: 8080});
  
console.log('Starting server');
wss.on('connection', function(ws) {
 
 console.log('user is connected');
 ws.send('user connected. Welcome.');
 
 ws.on('message', function(message) {
  console.log('received: %s', message);
  ws.send('Response to ' + message);
 });

 ws.on('disconnect', function() {
  console.log('user disconnected');
 });
});

Happy codding!

6 comments:

  1. Very Good Blog. Highly valuable information have been shared.Great information has been shared. We expect many more blogs from the author. Special thanks for sharing..
    software testing services
    software testing companies
    Regression testing services
    Performance testing Services
    Test automation services

    ReplyDelete
  2. Recently, id verification service is much higher in requirement. There are many id verification methods that one can acquire on a dependable site known as Trust Swiftly, and a company can apply the methods to safe their own ecommerce site effortlessly. If you explore this amazing https://trustswiftly.com/ web site, you'll receive a lot more specifics about id verification service.

    ReplyDelete
  3. I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post. Penetration Testing Provider

    ReplyDelete
  4. I should say convert pdf to docx only that its awesome! The blog is informational and always produce amazing things

    ReplyDelete
  5. You have performed a great job on this article. It’s very precise and highly qualitative. convert pdf to png

    ReplyDelete