Git Product home page Git Product logo

photon-packet-parser's Introduction

photon-packet-parser

The photon-packet-parser is a Python library designed to parse and analyze packets transmitted using the Photon Protocol16 based on the C# library coded by 0blu. This library provides developers with a convenient way to decode and inspect Photon Protocol packets in their Python applications.

Warning

This library is incomplete as I merely needed some parts of it for my own project. I will add more features as I need them. It is not fully tested and far from being used in a production environment. If you need a feature that is not implemented yet, feel free to open an issue or submit a pull request.

Features

  • Parsing and decoding of Photon Protocol packets
  • Callbacks for handling different packet actions
  • Access to packet headers, payload, and metadata

Installation

You can install the photon-packet-parser library using pip:

pip install photon-packet-parser

Usage

To use the library, start by importing the PhotonPacketParser class:

from photon_packet_parser import PhotonPacketParser

Then, create an instance of the PhotonPacketParser class and provide the necessary callbacks:

def on_event(header, payload):
    # Callback for handling event packets
    pass

def on_request(header, payload):
    # Callback for handling request packets
    pass

def on_response(header, payload):
    # Callback for handling response packets
    pass

parser = PhotonPacketParser(on_event, on_request, on_response)

Once the parser object is created, you can use the handle_payload method to parse a payload:

payload_data = b'\x01\x02\x03\x04\x05\x06\x07\x08'
parser.handle_payload(payload_data)

The library will invoke the appropriate callback based on the packet type encountered during parsing.

For more advanced usage and customization options, please refer to the documentation.

Examples

Parsing a Photon Protocol packet

from photon_packet_parser import PhotonPacketParser

def on_event(header, payload):
    # Handle event packets
    print("Received event packet")

def on_request(header, payload):
    # Handle request packets
    print("Received request packet")

def on_response(header, payload):
    # Handle response packets
    print("Received response packet")

# Create a parser instance with callbacks
parser = PhotonPacketParser(on_event, on_request, on_response)

# Parse a payload
payload_data = b'\x01\x02\x03\x04\x05\x06\x07\x08'
parser.handle_payload(payload_data)

Contributing

Contributions to the photon-packet-parser library are welcome! If you find any bugs, have feature requests, or want to contribute improvements, please open an issue or submit a pull request on the GitHub repository.

When contributing, please follow the existing code style and ensure that all tests pass before submitting your changes.

License

The photon-packet-parser library is licensed under the MIT License. You are free to use, modify, and distribute this library in accordance with the terms of the license.

Acknowledgements

This library was inspired by 0blu implementation and the need for a Python parser.

photon-packet-parser's People

Contributors

santiac89 avatar zeldruck avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.