Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

⚠️The Decentraland API changed since this was made so it wont work. Please see https://decentraland.org/

Notifications You must be signed in to change notification settings

tcrowe/sample-sync-websockets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️The Decentraland API changed since this was made so it wont work. Please see https://decentraland.org/

sample-sync-websockets

This Decentraland scene demonstrates synchronization of state between networked users over websockets. The user should be able to connect and see other users interacting with the scene.

At this time Decentraland isn't rendering the avatars so imagine in this scene the "ghost cylinders" are like a force field around the players while they are in proximity to this scene.

  • See all users moving around the scene
  • Proximity activated tiles
  • Proximity activated door

example

How to do this


Two parts

The Decentraland Scene project is in ./scene.

The Server is in ./server.


Install

Install Decentraland CLI app

git clone https://github.com/tcrowe/sample-sync-websockets.git
cd sample-sync-websockets

# install scene packages
cd scene
npm install
npm start

# (in another terminal)
# install server packages
cd ../server
npm install
npm start

Windows users may require npm install --ignore-scripts to avoid compilation.

It's going to bind on two ports:

  • Decentraland preview server 127.0.0.1:8834
  • Websocket server 127.0.0.1:8835

Open the preview:

open http://127.0.0.1:8834

If you open it in multiple windows you can see the other players in the same scene.


Development

The ./scene project has these npm scripts:

# just build and exit
npm run build

# build and watch for changes
npm run watch

# start the preview server which runs also `npm run watch`
npm start

The ./server project has the following npm scripts:

# watch for changes in development and re-run the server
npm run watch

# run the server in production
npm start

Each project contains a ./lib directory. It's possible to adjust some settings in the following files:


Production

Publishing the scene on Decentraland

To to run the server in production you can cd server and npm start.

See also Host on Zeit Now


Contribute

If you notice that I've made an affront to correct TypeScript coding practices please forgive.

Others will want to use this as an example or starting place to fork from. If you see room for improvement please fork, mod, and send back here in a PR.

Thank you! 🤗

About

⚠️The Decentraland API changed since this was made so it wont work. Please see https://decentraland.org/

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published