Skip to main content

Talk to a socketio server

Project description

Smartphone Connector

This simple package exposes methods to interact with smartphones connected to a socket.io server instance.

Socket Server

This package talks with a socket.io server, which defines the following interface:

Events

  • device
    {
      'deviceId': str,
      'isController': bool,
      'deviceNr': int,
      'socketId': str
    }
    
  • `devices``
    [
      {
          'deviceId': str,
          'isController': bool,
          'deviceNr': int,
          'socketId': str
      },
      ...
    ]
    
  • all_data
    [
      {
          'deviceId': str,
          'timeStamp': int, # time (ms) since client loaded page,
          ...
      },
      ...
    ]
    
  • new_data
    {
      'deviceId': str,
      'timeStamp': int, # time (ms) since client loaded page,
      ...
    }
    

Actions (for emitting)

  • emit('clear_data', { 'deviceId': str })
  • emit('new_device', { 'deviceId': str })
  • emit('get_all_data', { 'deviceId': str })
  • emit('get_devices', { 'deviceId': str })
  • emit('new_data', { 'deviceId': str, timeStamp: int, ... })
  • emit('new_data', { 'deviceNr': int, timeStamp: int, ... })

A simple socket io server implementing this interface can be seen on github.com/lebalz/socketio_server. A running server is currently (August 2020) deployed under io.lebalz.ch.

Example

from smartphone_connecter
connector = Connector('https://io.lebalz.ch', 'FooBar')

# draw a 3x3 checker board
connector.set_grid([
    ['black','white','black'],
    ['white','black','white'],
    ['black','white','black']
], broadcast=True)

results on all devices in the following screen.

When broadcast is set to False (default), only the FooBar devices display the checker board.

checker board

Package and upload to pip

@see this tutorial

python3 setup.py sdist bdist_wheel
python3 -m twine upload dist/*

Project details


Release history Release notifications | RSS feed

This version

0.0.2

Download files

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

Source Distribution

smartphone-connector-0.0.2.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

smartphone_connector-0.0.2-py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 3

Supported by

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