How do you send a message using pyOSC?

hlupico

I'm very new to python and even less familiar with pyOSC. Can someone post a simple example of how to send a string message from my computer to another computer? I viewed this pyOSC link which has given me some guidance but I am uncertain why the addressSet() takes "/startup". Is this the function that receives the message on the other end or is it something else?

I greatly appreciate any guidance you can provide!

labradore

OSC has the concept of an message address that is distinct from the network address of the device to which you're connecting. The idea is that the message you are sending could be routed to one of many different handlers at the other end of the network connection. Each handler has its own address which is usually designated with a '/' prefix.

Using the same client code from the question you referenced:

import OSC

c = OSC.OSCClient()
c.connect(('127.0.0.1', 57120))   # localhost, port 57120
oscmsg = OSC.OSCMessage()
oscmsg.setAddress("/startup")
oscmsg.append('HELLO')
c.send(oscmsg)

First, run this server code:

import OSC

def handler(addr, tags, data, client_address):
    txt = "OSCMessage '%s' from %s: " % (addr, client_address)
    txt += str(data)
    print(txt)

if __name__ == "__main__":
    s = OSC.OSCServer(('127.0.0.1', 57120))  # listen on localhost, port 57120
    s.addMsgHandler('/startup', handler)     # call handler() for OSC messages received with the /startup address
    s.serve_forever()

Then run the client from a different terminal. On the server side you should get something like:

OSCMessage '/startup' from ('127.0.0.1', 55018): ['HELLO']

The best way to get more insight into how to use pyOSC is to just read the source. It's all in OSC.py and not too long. There is a test method at the bottom of the file that gives a fairly detailed examples of how to use most, if not all, of the protocol functionality.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do you send message using NFC with Xamarin.Android?

How Do You Send A Direct Message In Mattermost From A Bot Using The Go Driver?

How do you make a bot send a message to an specific guild in a specific channel without using commands

How do you tell if the message is from send or sendSync in the main process?

How do you use PHP to send form data as a message?

How do you make a discord bot that send a message if another user send a message? discord.py

How do I send a message to a window handle using AutoHotKey?

How do you send an API key to Datadog using urllib?

How do you send data in a Request body using HttpURLConnection?

How do you send XML files using Azure Storage Queue?

How do you send NumPad keys using SendKeys?

How do you send a txt message to a cell phone from a Lucee web app?

How do you send a message to the client when PHP form submission download fails

How do you send a private message on_ready aka on a @client.event. Discord.py

Socket.io 1.4.5 How do you send a message to an individual client in a room?

!FIXED! How do you send a message in a channel on startup in discord.js"

How do you send a private message in discord.py to command user?

How can you send an SMS message using pure HTTP post with no other libraries

How do you do an alert / message / popup box using JScript on Windows?

How do I send message programmatically in iPhone

How do I send a message to multiple processes

how do you send params to template

how do you send email from R

How do you send a certificate with an HttpRequestMessage?

How do you send an object to a helper in Handlebars?

How do you define a file response as a Message

How do you get the message from PlatformException?

"How do you want open this website?" message

How to send a ZMQ message using a reference?