DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
    • can-construct-super
    • can-define-stream
    • can-fixture
    • can-fixture-socket
      • types
        • SocketEventListener
      • properties
        • Server
          • prototype
            • emit
            • on
            • onFeathersService
            • restore
        • requestHandlerToListener
        • storeToListeners
    • can-jquery
    • can-stache-converters
    • can-stream
    • can-vdom
    • can-view-import
    • can-zone
    • steal-stache
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Ecosystem
  • /
  • can-fixture-socket
  • /
  • Server
  • /
  • on
  • / On this page
    • on

      function

      Adds a socket event listener.

      • source

      server.on(event, handler)

      Adds a socket event listener.

      server.on("notifications", function(data, ackFn){
        console.log("Received " + data);
        ackFn("Acknowledged, thank you");
      });
      

      Parameters

      1. event {string}:

        The name of the socket event to listen for.

      2. handler {SocketEventListener()}:

        The handler that will be executed to handle the socket event.

      server.on(eventsObject)

      A short hand method to add multiple event listeners.

      server.on({
        "news": handleNews,
        "tweets": handleTweets,
        "users": handleUsers
      });
      

      Parameters

      1. eventsObject {object}:

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.