Skip to main content

Python client and server for MinVR3

Project description

Python MinVR3 library

This package provides communication bindings for MinVR3 in Python. This is useful because the IV/LAB has historically used Python for many web server applications (Flask or Django), and it's useful to communicate between Unity and these servers in real-time.

The implementation here is based off of the MinVR3.cpp~ client and server.

Check the package out on PyPI:

MinVR3 Python Library on PyPI

Installation

You can install the minvr3 Python package from the Python package index using the following command:

python3 -m pip install --user minvr3

Getting Started

The Python MinVR3 client can function as a client or server. Look below for simple examples of running a MinVR3 client and server. Check out the apps folder for more complete examples.

Both the server and client implementation are compatible with the TcpJsonVREventConnection provided by the MinVR3-UnityPackage. You can have a Python server connect with a Unity client, and vice versa.

Server code

Copy/paste the following code to set up a simple server that sends 10 integer VR Events and listens for 10 integer VR Events:

import time
from minvr3 import minvr3_net

HOST = '127.0.0.1'
PORT = 9034

listener = minvr3_net.create_listener(HOST, PORT, 0)

# wait for 1 connection
while not minvr3_net.is_ready_to_read(listener):
    print('waiting for connection')
    time.sleep(1)

client = minvr3_net.try_accept_connection(listener)

if client is None:
    print('no connection')
    exit(1)

# test send/receive uint32
for count in range(10, 20):
    minvr3_net.send_uint32(client, count)
    print('sent', count)

for count in range(0, 10):
    c = minvr3_net.receive_uint32(client)
    print('got', c, 'expected', count)


minvr3_net.close_socket(client)

Client code

Copy/paste the following code to set up a simple client that sends 10 integer VR Events and listens for 10 integer VR Events:

from minvr3 import minvr3_net

HOST = '127.0.0.1'
PORT = 9034
print('Connecting to server', HOST, PORT)

server = minvr3_net.connect_to(HOST, PORT)

# test send/receive uint32
for count in range(10, 20):
    c = minvr3_net.receive_uint32(server)
    print('got', c, 'expected', count)

for count in range(0, 10):
    minvr3_net.send_uint32(server, count)
    print('sent', count)

minvr3_net.close_socket(server)

Relay server

In addition to example code, a pure Python relay server is also supplied. This server receives VREvents from clients, and relays them to all other clients.

To run the relay server, you can run:

python3 -m minvr3.apps.relay_server

Development Installation and Deploying a new package

Installing the dev version

To install the minvr3 Python package locally, run the following command in this folder:

python3 -m pip install --user --editable .

If you're on Windows, probably need to replace python3 with py in the above commands.

Deploying the package to PyPI

To do this, you will need an account on https://pypi.org and https://test.pypi.org.

Once you've made your changes, build the package, then deploy it to the Python Package Index.

First, make sure you have the build / deploy tools:

py -m pip install --user --upgrade build
py -m pip install --user --upgrade twine

Build it (run in this folder):

py -m build

Test deploy it (run in this folder):

py -m twine upload --verbose --repository testpypi dist/*

verify that it all looks good on the deployed test site: https://test.pypi.org/project/minvr3/

Then, actually deploy it:

py -m twine upload --verbose dist/*

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

minvr3-2023.8.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

minvr3-2023.8.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file minvr3-2023.8.0.tar.gz.

File metadata

  • Download URL: minvr3-2023.8.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for minvr3-2023.8.0.tar.gz
Algorithm Hash digest
SHA256 8a6ebdb0ac52c9e479781bed7dbe0fc9eacfa3cd1d5fabf9875f654cf21084f5
MD5 9bf260706de9f0c22d0d0c3b81e86b74
BLAKE2b-256 9dfd250e84ce01bbe8c2496cb5b44f7d2ee38d08c82f2954e977f3ea1ffd8078

See more details on using hashes here.

File details

Details for the file minvr3-2023.8.0-py3-none-any.whl.

File metadata

  • Download URL: minvr3-2023.8.0-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for minvr3-2023.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d3d89cee8a81a3d35c83bb67a1a08f19ed2f2ef5b05e87b95d8039fbd536a1f5
MD5 9ba714e9aff8afa9e0150d7e7b5b25ab
BLAKE2b-256 56f48ad251fdc1d283a6555680390ad08da09a0891a88fe1c0211a3dbe90644a

See more details on using hashes here.

Supported by

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