Skip to content

Modify browser location from server #158

Answered by mwx23
mwx23 asked this question in Q&A
Discussion options

You must be logged in to vote

Just an update on my implementation for those interested.

Also this solution means you should be able to run other DOM methods (completely untested, buyer beware...).
Obviously more care needs to be taken with the deserialisation from python. Perhaps a more formalised JSON structure.

// frontend.js
    lona_context.add_message_handler(function (lona_context, raw_message) {
        if (!raw_message.startsWith('custom-message:')) {
            return raw_message;
        }
        let [namespace, method, ...args] = raw_message.split(':');
        let cmd = `${method}(...args)`;
        let res = eval(cmd);
        // serialise res and send it back to the server 
        // lona_context.send…

Replies: 4 comments 9 replies

Comment options

You must be logged in to vote
1 reply
@fscherf
Comment options

Comment options

You must be logged in to vote
7 replies
@maratori
Comment options

@fscherf
Comment options

@fscherf
Comment options

@maratori
Comment options

@fscherf
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@fscherf
Comment options

Answer selected by mwx23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #157 on October 09, 2021 10:59.