1.2.0 • Published 2 years ago
croquet-proxy v1.2.0
croquet-proxy
A proxy for the Croquet platform.
How to use
- Install Node.js
- Create the project directory and navigate to it
- Run
npm init
and follow the instructions - Run
npm install croquet-proxy
- Define your own Model
// my-model.js
import { Model } from '@croquet/croquet';
class MyModel extends Model {
init(options) {
super.init(options);
// Define your model data always in the 'data' property
this.data = { counter: 0 }
this.future(1000).tick()
}
tick() {
this.data.counter++
this.publish('counter', 'updated')
this.future(1000).tick()
}
}
- Define the starting point of your application
// my-app.js
import { CroquetProxyServer } from 'croquet-proxy';
import { MyModel } from './my-model.js';
const apiKey = ""
const appId = ""
const name = ""
const password = ""
CroquetProxyServer.start({
mainModelClass: MyModel,
allModelClasses: [MyModel],
apiKey: apiKey,
appId: appId,
name: name,
password: password,
port: 3000
})
- Run
node my-app.js