Coder Social home page Coder Social logo

kokofixcomputers / koko-primitive-cloud-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sheeptester/primitive-cloud-server

0.0 0.0 0.0 42 KB

A primitive Node server for Scratch 3.0 cloud variables; it's not made for large-scale projects and can easily be tricked by those pesky JavaScript programmers

License: MIT License

JavaScript 80.80% CSS 7.59% HTML 11.61%

koko-primitive-cloud-server's Introduction

Primitive-cloud-server

A primitive Node server for Scratch 3.0 cloud variables; it's not made for large-scale projects and can easily be tricked by those pesky JavaScript programmers.

Run on Repl.it Edit in CodeSandbox

Video tutorial:

thumbnail of video tutorial

Install:

  1. You'll need to have Node installed first.

  2. git clone https://github.com/SheepTester/primitive-cloud-server.git
    cd primitive-cloud-server
    npm install
    npm start

This makes a local WebSocket server available at ws://localhost:3000/ and an HTTP server at http://localhost:3000/.

Cloud variables get stored in the cloud-vars/ folder.

You can pass a few command line arguments; like this npm start --help for a list.

Updating

You can update to a new version by doing

git stash
git pull
git stash pop
git checkout --theirs -- .
git reset HEAD
npm install

This "stashes" your local changes, pulls (downloads) the new files from GitHub, then tries to bring back the files from the stash. This might cause issues, so this then checks out "their" files ("their" refers to the stash that you're bringing back). For some reason, Git might get confused after this, so we just unstage all the files. Finally, it installs new dependencies from NPM.

Details

All WebSocket messages are JSON strings; the server may send multiple JSON objects separated by a newline character, but the client may not do that back.

When the client first connects to the server, Scratch sends a "handshake" message, which I think lets the server know which project it is on so the server can then send a series of "set" messages to initialize the client's cloud variables.

// client -> server
{ "method": "handshake", "project_id": "104" }

// server -> client
{ "method": "set", "name": "☁ cool cloud variable", "value": "45643563456" }
{ "method": "set", "name": "☁ epic cloud variable", "value": "10239489031" }
{ "method": "set", "name": "☁ newish variable", "value": "0" }

// client -> server
{ "method": "set", "name": "☁ cool cloud variable", "value": "123" }

koko-primitive-cloud-server's People

Contributors

sheeptester avatar kokofixcomputers avatar kianidev avatar dependabot[bot] avatar chiroyce1 avatar

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.