photon-observer


Namephoton-observer JSON
Version 0.1 PyPI version JSON
download
home_pagehttps://github.com/MyrikLD/photon_observer
SummaryTools for working with the Photon protocol
upload_time2023-06-27 17:05:16
maintainer
docs_urlNone
authorYorsh Sergey
requires_python
licenseMIT
keywords photon binary protocol
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Photon Observer

Tools for working with the [Photon protocol](https://doc.photonengine.com/realtime/current/reference/binary-protocol).

### Example:
```python
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](https://github.com/hmadison/photon_spectator) package

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/MyrikLD/photon_observer",
    "name": "photon-observer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "photon binary protocol",
    "author": "Yorsh Sergey",
    "author_email": "myrik260138@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/af/75/03dd869a46cb14ff547e27e80bfeb4c90ef26612687ce0314b41d8e14179/photon_observer-0.1.tar.gz",
    "platform": null,
    "description": "# Photon Observer\n\nTools for working with the [Photon protocol](https://doc.photonengine.com/realtime/current/reference/binary-protocol).\n\n### Example:\n```python\nimport pyshark\nimport io\nfrom photon_observer import PhotonLayer, FragmentBuffer, CommandType, ReliableMessage\n\ndef on_message(message: ReliableMessage):\n    pass\n\ndef main():\n    capture = pyshark.LiveCapture(\"wlp4s0\", bpf_filter=\"udp\")\n    buf = FragmentBuffer()\n\n    for p in capture.sniff_continuously():\n        payload = bytes.fromhex(p.udp.payload.replace(\":\", ''))\n        layer = PhotonLayer.unpack(io.BytesIO(payload))\n        \n        for cmd in layer.commands:\n            if cmd.type == CommandType.SendReliableType:\n                msg = cmd.reliable_message()\n                on_message(msg)\n            elif cmd.type == CommandType.SendUnreliableType:\n                _cmd = cmd.unreliable_type()\n                msg = _cmd.reliable_message()\n                on_message(msg)\n            elif cmd.type == CommandType.SendReliableFragmentType:\n                msg = cmd.reliable_fragment()\n                result = buf.offer(msg)\n                if result is not None:\n                    msg = result.reliable_message()\n                    on_message(msg)\n            else:\n                continue\n```\n\n## PS\nAdditional thanks to @hmadison for his [photon_spectator](https://github.com/hmadison/photon_spectator) package\n\n## License\nThis project is licensed under MIT. Contributions to this project are accepted under the same license. \n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Tools for working with the Photon protocol",
    "version": "0.1",
    "project_urls": {
        "Homepage": "https://github.com/MyrikLD/photon_observer"
    },
    "split_keywords": [
        "photon",
        "binary",
        "protocol"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9cdfc522a62206fe5f0e8acb8b88be4e7e9db92a05852689f4859b0f3ee83747",
                "md5": "4e9cbe0d56a09c182fdd56d5d0e1fd11",
                "sha256": "92381bffa31410d0bdfa974c07e466f139cf3a4f254a38d6197d17107533e8f4"
            },
            "downloads": -1,
            "filename": "photon_observer-0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4e9cbe0d56a09c182fdd56d5d0e1fd11",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7323,
            "upload_time": "2023-06-27T17:05:14",
            "upload_time_iso_8601": "2023-06-27T17:05:14.879174Z",
            "url": "https://files.pythonhosted.org/packages/9c/df/c522a62206fe5f0e8acb8b88be4e7e9db92a05852689f4859b0f3ee83747/photon_observer-0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af7503dd869a46cb14ff547e27e80bfeb4c90ef26612687ce0314b41d8e14179",
                "md5": "c08b7844ef52b1452dc9cbff577bd1a6",
                "sha256": "12f7bf3f893d061c2e829a559303bc5e88bc58edc4965543a8bf7a165517c34f"
            },
            "downloads": -1,
            "filename": "photon_observer-0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "c08b7844ef52b1452dc9cbff577bd1a6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8067,
            "upload_time": "2023-06-27T17:05:16",
            "upload_time_iso_8601": "2023-06-27T17:05:16.258338Z",
            "url": "https://files.pythonhosted.org/packages/af/75/03dd869a46cb14ff547e27e80bfeb4c90ef26612687ce0314b41d8e14179/photon_observer-0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-27 17:05:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MyrikLD",
    "github_project": "photon_observer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "photon-observer"
}
        
Elapsed time: 1.73757s