• Stars
    star
    135
  • Rank 269,297 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 3 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Javascript library for easily building shared applications such as chats and games.

co-share

Build Status  Npm package version  GitHub license  Twitter

Javascript library for easily building shared applications such as chats and games

Transformable Example

A shared 3D Cube with "Alice" and "Bob" as simulated users.
The Example was built with co-share and react-three-fiber

npm i co-share

When to use

Building multiuser applications for the web is often challenging as asynchronous communication can drastically increase the system complexity. Writing robust and performant shared applications requires a structured and fitting architecture.

We propose the abstraction of shared stores to distribute logic and data between participating systems. By using Javascript & Node.js, the same code can be used on the client and the server to carry out the platform-independent communication.

How to use

The library is framework-independent as it runs on the Web and NodeJS. However, we provide react hooks out of the box to simplify the experience. Please help us to build tools for more web frameworks.

new Example extends Store {
    action = Action.create(this, "actionName", (origin, parameter) => {
        action.publishTo(
            origin == null ?
                { to: "all" } :
                { to: "all-except-one", except: origin },
            parameter
        )
    })
}

The Stores contain both, the platform-independent logic and the data. Platform independent logic is specified as Actions, which are methods that can be invoked on a remote client (similar to RPC/RMI). Above, we use publishTo to make the Store execute the given Action with the provided parameter on all nodes linked to this Store.

Tutorial

We will build a globally synchronized counter and display it using react. Every client can increase the counter.

Counter Example

Above, you can see a local simulation with the clients "Alice" and "Bob". Even though we can simulate the communication locally, this library is meant for networked communication using WebSocket or WebRTC.

Examples

The code for each example can be found on the respective pages

Simulated locally in your browser

  • Request - request response paradigma
  • Message - direct client to client messaging without any persistent storage in between
  • Lockable - advanced lock functionality to prevent editing by multiple people simultaneously
  • Optimistic Lockable - performance optimize lockable that allows for optimistic behaviour and error correction
  • Whiteboard - collaborative drawing on a shared whiteboard
  • Transformable - shared 3D transformation
  • Consistent - continous states with client-side prediction, lag-compensation and smoothing (using co-consistent)

An extra Project with a server/client architecture using SocketIO

Example Architecture

Sample Architecture Graph

In a multiuser scenario, stores are connected using StoreLinks. One Store can have 0-N StoreLinks to other participants.

In depth description

This framework revolves around the idea of Stores, which can represent any entity or information. A Store is a class that may contain a set of Actions which are methods that can be executed remotely. The communication for executing an action remotely is carried out by the connection of your choice, for instance, with socketio.

However, executing an Action requires an established StoreLink for a connection. This StoreLink uniquely identifies the relation between local Store and remote Store and vice versa. Setting up a StoreLink can be done manually or automatically by subscribing to a certain Store. When subscribing to a Store from a host, its Store will provide the initial parameters to create a local copy of that Store. A Subscriber provides the parameters running on every Store to determine if and what a requesting client should know about the Store. Subscribers can also deny a subscription request.

Supporting Packages

More Repositories

1

koestlich

user interfaces for three.js
TypeScript
293
star
2

natuerlich

webxr interaction for three.js
TypeScript
160
star
3

apfel-kruemel

Pre-Designed Component Library for Spatial User Interfaces
TypeScript
35
star
4

media

React library for accessing browser media like camera, microphone, screen capture, etc.
TypeScript
27
star
5

kritzeln

TypeScript
23
star
6

hochhaus

In the city's embrace, a building with grace, where elevators ascend, and dreams find their space
TypeScript
10
star
7

co-flex

React library for an unopinionated flexbox binding using yoga
TypeScript
9
star
8

glyph

fast, efficient, and layout-ready text rendering for Three.js
TypeScript
7
star
9

getting-started

Getting started with the coconut-xr ecosystem
TypeScript
6
star
10

auto

TypeScript
5
star
11

spatial-ui-example

Music Library using state-of-the-art Design in an interactive Spatial User Interface.
TypeScript
5
star
12

xinteraction

interactions for three.js
TypeScript
5
star
13

co-consistent

globally consistent event ordering for decentralized distributed systems
TypeScript
5
star
14

input

TypeScript
5
star
15

co-share-peer

Peer to peer functionality for co-share using simple-peer (webrtc)
TypeScript
4
star
16

pose-booth

TypeScript
4
star
17

flex

typescript css flexbox properties for yoga
TypeScript
3
star
18

klettern

@coconut-xr/natuerlich - climbing demo
TypeScript
3
star
19

co-share-peer-room

p2p room functionality for co-share-peer
TypeScript
2
star
20

co-share-socketio

networking implementation using socketio for co-share
TypeScript
1
star
21

co-virtualize

co-virtualize enables the extension and decoupling of a react component's livetime.
TypeScript
1
star
22

koestlich-expo-test

TypeScript
1
star