Git Product home page Git Product logo

Comments (5)

ericz avatar ericz commented on June 16, 2024

Hey Tom,

We've added the clientWrite option which allows you to stop clients from writing to the server.

 nowjs.initialize(httpServer, {clientWrite: false});

However changes are rejected on the server side so it is important to make sure that any type of data sent to the server is rejected if it surpasses a certain size

from now.

balupton avatar balupton commented on June 16, 2024

Sweet, it does seem like a big security issue with having clientWrite as true.

So with:

nowjs.initialize(httpServer, {clientWrite: false});

What's the best practice equivalent of:

now.receiveMessage = function(name, message){
  $("#messages").append("<br>"+name+": "+message);
}

I couldn't get the following to work:

Server:

/**
 * Meet the client
 * @return {integer} id
 */
everyone.now.meet = function(options,_callback){
    // Apply Options
    if ( typeof options.notify === 'function' ) {
        this.now.notify = options.notify;
    }

    // Next
    _callback(this.now.id);
};

// ...
everyone.now.notify(n);

Client:

// Now
window.now.ready(function(){
    // Bind Now
    window.now.meet(
        // Options
        {
            notify: function(_state){
                if ( _state !== me.currentState ) {
                    me.reset();
                }
            }
        },
        // Callback
        function(_id){
            // Apply Id
            document.title = me.id = _id;

            // Init Sync
            me.reset();
        }
    );
});

Returns error on server:

TypeError: Object #<Object> has no method 'notify'
    at Object.<anonymous> (/Users/balupton/Dropbox/Server/public_html/sites/nowpad/server.js:180:16)
    at Object.<anonymous> (native)
    at Object.remoteCall (/usr/local/lib/node/.npm/now/0.5.2/package/lib/nowServerLib.js:49:19)
    at [object Object].<anonymous> (/usr/local/lib/node/.npm/now/0.5.2/package/lib/nowServerLib.js:173:46)
    at [object Object].emit (events.js:64:17)
    at [object Object]._onMessage (/usr/local/lib/node/.npm/socket.io/0.6.17/package/lib/socket.io/client.js:58:10)
    at Parser.<anonymous> (native)
    at Parser.emit (events.js:64:17)
    at Parser.parse (/usr/local/lib/node/.npm/socket.io/0.6.17/package/lib/socket.io/transports/websocket.js:195:12)
    at Parser.add (/usr/local/lib/node/.npm/socket.io/0.6.17/package/lib/socket.io/transports/websocket.js:182:8)

from now.

ericz avatar ericz commented on June 16, 2024

@balupton

Hmm I believe there is an outstanding bug with nested functions being passed as parameters. So options.notify is not being actually passed the server

from now.

balupton avatar balupton commented on June 16, 2024

@ericz

Yeah, passing the notify function as an argument rather than inside an object worked great. Would you like me to file a bug for sending objects to the server?

from now.

ericz avatar ericz commented on June 16, 2024

Yep that'd be very helpful, thanks!

On Sun, Apr 24, 2011 at 8:32 PM, balupton <
[email protected]>wrote:

@ericz

Yeah, passing the notify function as a argument rather than inside an
object worked great. Would you like me to file a bug for sending objects to
the server?

Reply to this email directly or view it on GitHub:
#44 (comment)

510-691-3951
EECS Student at UC Berkeley
http://ericzhang.com

from now.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.