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
        • 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
  • /
  • SocketEventListener
  • / On this page
    • SocketEventListener

      typedef

      A listener handler that will be executed to handle the socket event.

      • source

      handler(...data, [ackFn])

      Socket event listener handler expects one or more data arguments and an optional ACK callback.

      // Client:
      socket.on("news": function handler(data, ackCb){
        console.log("received some news", data);
        ackCb("Acknowledged", "thank you");
      });
      
      // Server:
      server.emit("news", {some: "news here"}, function ackFn(...data){
        console.log("Client acknowledged data receiving")
      });
      

      Parameters

      1. data {*}:

        Event data. Socket.io allows to pass as many arguments as needed.

      2. ackCb {function}:

        Optional acknowledgement callback to let emitter know about success receiving data.

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