Skip to main content

Python Server Library for NOODLES Protocol

Project description

Rigatoni

Build Status PyPI Coverage

Python Server Library for NOODLES Protocol

Description

This server library implements the NOODLES messaging protocol and provides objects for maintaining a scene in state. The server uses a websocket connection to send CBOR encoded messages. To customize its implementation, the library provides convenient interface methods to assist the user in writing their own methods for the server. The user can also add custom delegates to add additionaly functionality to any of the standard components.

How does the server work?

The server handles incoming websocket connections and maintains a list of clients that are currently connected. After a client has sent an introductory message, they are free to invoke methods disclosed by the server. The server parses each message and attempts to invoke a corresponding message which has been injected by the user. The server calls this method and sends a reply with either a response or an exception.

sequenceDiagram
    participant User
    participant Method
    participant Server
    participant Client
    User->>Method: Defines Methods and Components
    User->>Server: Starts Server with Starting State
    Client->>Server: Sends Intro Message
    Server->>Client: Updates the Client with Current State
    loop until end of session
        Client->>Server: Request to Invoke Method
        Server->>Method: Invokes Method
        Method->>Server: Invokes Signals, Creates, Updates, and Deletes Components
        Server->>Client: Broadcasts Component Changes to All Clients
        Server->>Client: Sends Method Reply with Response or Exception
    end

Getting Started

1. Install the server library

pip install rigatoni

2. Define components to be held in the server's starting state

  • Use starting component objects to help with the creation of these components
rigatoni.StartingComponent(Type[Component], dict[Component_Attr, Value])
  • You can refer to the objects listed in noodle_objects.py to find all the available components along with their mandatory, default, and optional attributes. Additional information on NOODLE components and their attributes can be found here
  • Note that components must be initialized with keyword arguments to allow for validation
  • When creating methods, an additional callable object should be attached. This method will be injected onto the server object, and it will be associated with its corresponding method component.
rigatoni.StartingComponent(Type[Component], dict[Component_Attr, Value], Callable)

3. Start running the server

server = Server(50000, starting_state, delegates)
server.run()
server.shutdown()

or alternatively, you can use the context manager to automatically start running the server in a new thread

with Server(50000, starting_state, delegates) as server:
    # do stuff

More Info on Creating Methods

The majority of the user's time building a server application will be spent defining methods. To help the user with this process, this library provides several interface methods to reduce friction when interacting with state and the server object. Also it is important to note that each method is injected and called so that the first two arguments are a reference to the server object and the method invoke's context as a dict.

Interface Methods

server.create_component(comp_type: Type[Component], **kwargs)
server.delete_component(obj: Union[Component, Delegate, ID])
server.update_component(obj: Component, delta: Set[str)
server.invoke_signal(signal: ID, on_component: Component, signal_data: list[Any])
server.get_ids_by_type(component: Type[Component])
server.get_component_id(type: Type[Component], name: str)
server.get_component(id: ID)

Geometry Library

Creating a renderable entity is an involved process that makes use of several different components. To help simplify this process the library provides methods to create all the linked components necessary for a mesh.

rigatoni.geometry.GeometryPatchInput(
    vertices: list
    indices: list
    index_type: str 
    material: MaterialID
    normals: Optional[list] 
    tangents: Optional[list]
    textures:Optional[list] 
    colors: Optional[list]
)
rigatoni.geometry.build_geometry_patch(server: Server, name: str, input: GeometryPatchInput)

instances = rigatoni.geometry.create_instances(
    positions: Optional[list[nooobs.Vec3]], 
    colors: Optional[list[nooobs.Vec4]], 
    rotations: Optional[list[nooobs.Vec4]], 
    scales: Optional[list[nooobs.Vec3]]
)
rigatoni.geometry.build_entity(server: Server, geometry: Geometry, instances: Optional[Mat4])

rigatoni.geometry.update_entity(server: Server, entity: Entity, geometry: Optional[Geometry], instances: Optional[Mat4])
rigatoni.geometry.add_instances(server: Server, entity: Entity, instances: Mat4)

Hungry for more NOODLES?

For more information and other related repositories check out this repository

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rigatoni-0.1.14.tar.gz (3.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rigatoni-0.1.14-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file rigatoni-0.1.14.tar.gz.

File metadata

  • Download URL: rigatoni-0.1.14.tar.gz
  • Upload date:
  • Size: 3.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for rigatoni-0.1.14.tar.gz
Algorithm Hash digest
SHA256 c67e251bbe4e114221d1af9ec57c9b3892560cdcc340e0c2c4a33ac48d341e58
MD5 ce45da426fffd0d6e591775c81600da6
BLAKE2b-256 b0243ea698f2ad8d50a65fdf4fbe8ed68b5049c4143afc002b452bb1b068cdd6

See more details on using hashes here.

File details

Details for the file rigatoni-0.1.14-py3-none-any.whl.

File metadata

  • Download URL: rigatoni-0.1.14-py3-none-any.whl
  • Upload date:
  • Size: 25.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for rigatoni-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 cc855b261030263c5569126b2264c65039ba79f541383dda43b49adf6379c571
MD5 ea0832142599c8a1173e9de85de2b96c
BLAKE2b-256 0970b7e2760b74569c03508fe52ae7c7067ef635a684dc3a16c8f25190c61685

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page