lib/server.js
function onevent(event) {
        // Event should have the following properties:
        // * `id: string`: an event identifier.
        // * `type: string`: an event type.
        // * `data: any`: an event data.
        // * `reply: boolean`: true if this event requires the reply.

        // If the client sends a plain event, dispatch it.
        if (!event.reply) {
          self.emit(event.type, event.data);
        } else {
          var latch;
          // A function to create a function.
          function reply(success) {
            // A controller function.
            return function(value) {
              // This latch prevents double reply.
              if (!latch) {
                latch = true;
                self.send("reply", {id: event.id, data: value, exception: !success});
              }
            };
          }

          // Here, the controller is passed to the event handler as 2nd argument and allows
          // to call the server's `resolved` or `rejected` callback by sending `reply` event.
          self.emit(event.type, event.data, {resolve: reply(true), reject: reply(false)});
        }
      }
function onevent(event) {
        // Event should have the following properties:
        // * `id: string`: an event identifier.
        // * `type: string`: an event type.
        // * `data: any`: an event data.
        // * `reply: boolean`: true if this event requires the reply.

        // If the client sends a plain event, dispatch it.
        if (!event.reply) {
          self.emit(event.type, event.data);
        } else {
          var latch;
          // A function to create a function.
          function reply(success) {
            // A controller function.
            return function(value) {
              // This latch prevents double reply.
              if (!latch) {
                latch = true;
                self.send("reply", {id: event.id, data: value, exception: !success});
              }
            };
          }

          // Here, the controller is passed to the event handler as 2nd argument and allows
          // to call the server's `resolved` or `rejected` callback by sending `reply` event.
          self.emit(event.type, event.data, {resolve: reply(true), reject: reply(false)});
        }
      }
function onevent ( event ) { // Event should have the following properties: // * `id: string`: an event identifier. // * `type: string`: an event type. // * `data: any`: an event data. // * `reply: boolean`: true if this event requires the reply. // If the client sends a plain event, dispatch it. if ( ! event . reply ) { self . emit ( event . type , event . data ) ; } else { var latch ; // A function to create a function. function reply ( success ) { // A controller function. return function ( value ) { // This latch prevents double reply. if ( ! latch ) { latch = true ; self . send ( "reply" , { id : event . id , data : value , exception : ! success } ) ; } } ; } // Here, the controller is passed to the event handler as 2nd argument and allows // to call the server's `resolved` or `rejected` callback by sending `reply` event. self . emit ( event . type , event . data , { resolve : reply ( true ) , reject : reply ( false ) } ) ; } }
When an event object is created from `text` or `binary` event.
When an event object is created from text or binary event .