Skip to main content

Photon Observer

Tools for working with the Photon protocol.

Example:

import pyshark
import io
from photon_observer import PhotonLayer, FragmentBuffer, CommandType, ReliableMessage

def on_message(message: ReliableMessage):
    pass

def main():
    capture = pyshark.LiveCapture("wlp4s0", bpf_filter="udp")
    buf = FragmentBuffer()

    for p in capture.sniff_continuously():
        payload = bytes.fromhex(p.udp.payload.replace(":", ''))
        layer = PhotonLayer.unpack(io.BytesIO(payload))
        
        for cmd in layer.commands:
            if cmd.type == CommandType.SendReliableType:
                msg = cmd.reliable_message()
                on_message(msg)
            elif cmd.type == CommandType.SendUnreliableType:
                _cmd = cmd.unreliable_type()
                msg = _cmd.reliable_message()
                on_message(msg)
            elif cmd.type == CommandType.SendReliableFragmentType:
                msg = cmd.reliable_fragment()
                result = buf.offer(msg)
                if result is not None:
                    msg = result.reliable_message()
                    on_message(msg)
            else:
                continue

PS

Additional thanks to @hmadison for his photon_spectator package

License

This project is licensed under MIT. Contributions to this project are accepted under the same license.

Release files for photon-observer 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for photon-observer 0.1
File Size Uploaded
photon_observer-0.1.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for photon-observer 0.1
File Interpreter ABI Platform
photon_observer-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / photon_observer-0.1.tar.gz

Download URL photon_observer-0.1.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
12f7bf3f893d061c2e829a559303bc5e88bc58edc4965543a8bf7a165517c34f
BLAKE2b-256 checksum
How to use checksums
af7503dd869a46cb14ff547e27e80bfeb4c90ef26612687ce0314b41d8e14179
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.1 CPython/3.11.4

Release files / photon_observer-0.1-py3-none-any.whl

Download URL photon_observer-0.1-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92381bffa31410d0bdfa974c07e466f139cf3a4f254a38d6197d17107533e8f4
BLAKE2b-256 checksum
How to use checksums
9cdfc522a62206fe5f0e8acb8b88be4e7e9db92a05852689f4859b0f3ee83747
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.1 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page