PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/socket.io-client/socket.io-client-tests.ts

https://github.com/vilic/DefinitelyTyped
TypeScript | 57 lines | 47 code | 9 blank | 1 comment | 0 complexity | 463cf95dd069eff05c871e5137a59c58 MD5 | raw file
Possible License(s): MIT
  1. /// <reference path="socket.io-client.d.ts"/>
  2. function testUsingWithNodeHTTPServer() {
  3. var socket = io('http://localhost');
  4. socket.on('news', function (data: any) {
  5. console.log(data);
  6. socket.emit('my other event', { my: 'data' });
  7. });
  8. }
  9. function testUsingWithExpress() {
  10. var socket = io.connect('http://localhost');
  11. socket.on('news', function (data: any) {
  12. console.log(data);
  13. socket.emit('my other event', { my: 'data' });
  14. });
  15. }
  16. function testUsingWithTheExpressFramework() {
  17. var socket = io.connect('http://localhost');
  18. socket.on('news', function (data: any) {
  19. console.log(data);
  20. socket.emit('my other event', { my: 'data' });
  21. });
  22. }
  23. function testRestrictingYourselfToANamespace() {
  24. var chat = io.connect('http://localhost/chat')
  25. , news = io.connect('http://localhost/news');
  26. chat.on('connect', function () {
  27. chat.emit('hi!');
  28. });
  29. news.on('news', function () {
  30. news.emit('woot');
  31. });
  32. }
  33. function testSendingAndGettingData() {
  34. var socket = io();
  35. socket.on('connect', function () {
  36. socket.emit('ferret', 'tobi', function (data: any) {
  37. console.log(data);
  38. });
  39. });
  40. }
  41. function testUsingItJustAsACrossBrowserWebSocket() {
  42. var socket = io('http://localhost/');
  43. socket.on('connect', function () {
  44. socket.emit('hi');
  45. socket.on('message', function (msg: any) {
  46. });
  47. });
  48. }