Tools for working with the Photon protocol
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
photon_observer-0.1.tar.gz
(8.1 kB
view hashes)
Built Distribution
Close
Hashes for photon_observer-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92381bffa31410d0bdfa974c07e466f139cf3a4f254a38d6197d17107533e8f4 |
|
MD5 | 4e9cbe0d56a09c182fdd56d5d0e1fd11 |
|
BLAKE2b-256 | 9cdfc522a62206fe5f0e8acb8b88be4e7e9db92a05852689f4859b0f3ee83747 |