Skip to content

Add Int64 support (OSC Type h) - #145

Merged
attwad merged 4 commits into
attwad:masterfrom
cansik:int64-support
Oct 2, 2021
Merged

Add Int64 support (OSC Type h)#145
attwad merged 4 commits into
attwad:masterfrom
cansik:int64-support

Conversation

@cansik

@cansik cansik commented Oct 1, 2021

Copy link
Copy Markdown
Contributor

I have implemented the long requested Int64 support in #21 . I followed the code style of the UInt64 and Integer implementation.

Here is an example script to test it, unit tests are implemented as well.

import threading
import time

from pythonosc.dispatcher import Dispatcher
from pythonosc.osc_message_builder import OscMessageBuilder
from pythonosc.udp_client import SimpleUDPClient
from pythonosc import osc_server

HOST = "127.0.0.1"
PORT = 7500
ADDRESS = "/test"


def start_listener():
    dispatcher = Dispatcher()
    dispatcher.map(ADDRESS, print)

    server = osc_server.ThreadingOSCUDPServer(
        (HOST, PORT), dispatcher)
    print("Serving on {}".format(server.server_address))
    server.serve_forever()


def main():
    threading.Thread(target=start_listener).start()

    sender = SimpleUDPClient(HOST, PORT)
    running = True
    while running:
        builder = OscMessageBuilder(address=ADDRESS)

        # add integer with type inference
        builder.add_arg(5000)

        # add integer with explicit type
        builder.add_arg(32003, arg_type=OscMessageBuilder.ARG_TYPE_INT)

        # add integer at upper limit
        builder.add_arg(pow(2, 32))

        # add int64 with type inference
        builder.add_arg(pow(2, 40))

        # add int64 with explicit type
        builder.add_arg(34359738368, arg_type=OscMessageBuilder.ARG_TYPE_INT64)

        # epoch time with type inference
        builder.add_arg(time.time_ns() // 1_000_000)

        sender.send(builder.build())

        time.sleep(0.5)


if __name__ == "__main__":
    main()

@attwad

attwad commented Oct 2, 2021

Copy link
Copy Markdown
Owner

thank you for the PR!

@attwad
attwad merged commit 3d8c01f into attwad:master Oct 2, 2021
@attwad

attwad commented Oct 2, 2021

Copy link
Copy Markdown
Owner

I'll try to find time to push a new version this weekend 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants