View unanswered posts | View active topics It is currently Sat May 18, 2013 5:37 pm



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 66 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
 BBSocket 0.0.5 
Author Message
BBDinosaur
User avatar

Joined: Wed Dec 13, 2006 7:33 pm
Posts: 263
Location: Pretoria, South Africa
Reply with quote
Post 
The way bro@ms are implemented by blackbox, there is no registration process. All bro@ms (execpt the core bro@ms, which the core intercepts) are sent to all plugins which subscribe to recieve bro@ms, which AFIAK most do (including bbSocket). Plugins then compare each bro@m recieved to the bro@ms the plugin uses, and performs an action when it finds a match.

bbSockets passes each bro@m it recieves to the connected programs, which can then implement actions if they recieve a bro@m which they consider to be theirs.

To effectively respond to bro@ms in real time however, a program needs to continously read from the socket.

Testprog does this using non-blocking sockets and looping continously, calling the read function on each loop. This unfortunatly drives CPU usage to 100%

bbSocket does this (so that it can respond to connected programs) using asynchronous sockets, which causes windows to notify bbSocket when data has come in on the socket. bbSocket then uses read, because it knows data is present.

Python also allows the use of asynchronous sockets via the "asynccore" (or that might be "asyncore") module, which allows you to define callback functions.

The external program can also inject bro@ms into the core by sending @broamToSend across the socket(which cowmag is using to trigger bbBalloon), which is then passed into the core, and thus broadcast to all blackbox plugins.

I think this is what you you were asking about.


Tue Jan 16, 2007 8:22 am
Report this post
Profile WWW
Sponsored Links
Google Adsense


Moderator
User avatar

Joined: Sat Dec 11, 2004 12:06 am
Posts: 1310
Location: Violent Paradise
Reply with quote
Post 
Well, it has been a while since I could play some more with this and I'm still kind busy ATM but, I had tried to setup some BBInterface buttons to send ficticious bro@ms and I couldn't get my python script to receive them. Also, keeping an eye on my toolbar - it didn't appear that the bro@ms were even being passed or recognized by Blackbox as no messages were displayed.

But I'll give it another shot when I get some time, maybe it was something wrong with my script - but, using the same script to receive bbBalloon bro@ms worked...

_________________
I'll have the roast duck... with mango sauce and a large helping of BB4Win Wiki: http://wiki.bb4win.org/wiki/Main_Page


Tue Jan 16, 2007 2:45 pm
Report this post
Profile
Site Admin
User avatar

Joined: Sun Dec 05, 2004 8:59 pm
Posts: 1316
Location: Boise, Idaho
Reply with quote
Post 
I've got bbPyInterWeatherExtravaganza working on the asyncore (actually using asynchat as it's more of a client library where asyncore seems more server orriented). nothing completed at this time but I can attest to the fact that BBSocket does send every bro@m issued to the plugins (and you can respond to them with all kinds of fun things.) Like sending @PluginShow on an @PluginHide (message name wrong but you get the idea)

I'm bad :D

_________________
-- Brian


Tue Jan 16, 2007 10:16 pm
Report this post
Profile ICQ YIM WWW
BBDinosaur
User avatar

Joined: Fri Jan 27, 2006 4:16 am
Posts: 794
Location: Karlstad, Sweden
Reply with quote
Post 
Carsomyr wrote:
The external program can also inject bro@ms into the core by sending @broamToSend across the socket(which cowmag is using to trigger bbBalloon), which is then passed into the core, and thus broadcast to all blackbox plugins.

I think this is what you you were asking about.


So, if i add to my menu:

[exec] (Poke nose) {@RemoveBooger}

A program connected to bbSocket would receive that, and hopefully be able to virtually.. well.. you get the idea? :D

Cheers,
Christopher

_________________
Don't forget to check the BlackBox FAQs.

Jabber: noccy@jabber.se | Web: www.noccy.com | Blog: Minimal Security


Tue Jan 16, 2007 11:41 pm
Report this post
Profile ICQ YIM WWW
Site Admin
User avatar

Joined: Sun Dec 05, 2004 8:59 pm
Posts: 1316
Location: Boise, Idaho
Reply with quote
Post 
yes

_________________
-- Brian


Wed Jan 17, 2007 4:26 am
Report this post
Profile ICQ YIM WWW
BBDinosaur
User avatar

Joined: Fri Jan 27, 2006 4:16 am
Posts: 794
Location: Karlstad, Sweden
Reply with quote
Post 
Nice :)

Working on a NanoPlayer plugin now to integrate with bbSocket. Considering that the blackbox interface renders the gradients from the current style, we could soon have a player that changes its look with the style :D

_________________
Don't forget to check the BlackBox FAQs.

Jabber: noccy@jabber.se | Web: www.noccy.com | Blog: Minimal Security


Wed Jan 17, 2007 4:37 am
Report this post
Profile ICQ YIM WWW
BBDinosaur
User avatar

Joined: Fri Jan 27, 2006 4:16 am
Posts: 794
Location: Karlstad, Sweden
Reply with quote
Post 
Hm. Doing some testing, and i'm not receiving any notification of style changes? Could this be implemented or am i just doing something wrong? :D

Cheers,
Chris

_________________
Don't forget to check the BlackBox FAQs.

Jabber: noccy@jabber.se | Web: www.noccy.com | Blog: Minimal Security


Thu Jan 18, 2007 11:19 pm
Report this post
Profile ICQ YIM WWW
BBDinosaur
User avatar

Joined: Wed Dec 13, 2006 7:33 pm
Posts: 263
Location: Pretoria, South Africa
Reply with quote
Post 
There isn't a specific notification for styles, but changing a style does generate a BB_RECONFIGURE message.

You could try
Code:
subscribe("BB_RECONFIGURE")
and then request the current style whenever you recieve a BB_RECONFIGURE message by using
Code:
stylePath("NULL")
That should allow you to change styles whenever Blackbox does. You might need to put a slight delay between recieving the BB_RECONFIGURE and requesting the style file (I'm not sure whether the message occurs just before or just after the actual change in style file).

The BB_RECONFIGURE message from bbSocket looks like this
Code:
[BB_RECONFIGURE]
.

The above should work, but in case it doesn't I'll start looking around in the blackbox API to see if there is a specific notification for when the style changes.

If anybody knows about such a notification, could you please post it here?


Fri Jan 19, 2007 11:57 am
Report this post
Profile WWW
Site Admin
User avatar

Joined: Sun Dec 05, 2004 8:59 pm
Posts: 1316
Location: Boise, Idaho
Reply with quote
Post 
BB_RECONFIGURE is sent after the style has been changed or the user has requested a reconfig. If you do a GetStyleFile it will give you the new style.

_________________
-- Brian


Fri Jan 19, 2007 6:24 pm
Report this post
Profile ICQ YIM WWW
BBWise

Joined: Tue Aug 23, 2005 2:50 pm
Posts: 59
Location: England
Reply with quote
Post bb-osc 0.0.1
Implementation of an open sound control protocol -> bb python script using BBsocket.
Check http://opensoundcontrol.org too!

As it is only half finished, only sending broams to bb via osc works atm.

I'm still figuring out how to listen for broams and the call a send to osc function outside the infinite loop (this is my first python project ever)

Requirements: SimpleOSC : v0.2.3 for python and pd extended (for testing)

Attachments deleted as 0.0.2 is far superior.


Last edited by sammynono on Thu Jul 26, 2007 12:09 am, edited 1 time in total.



Sun Jul 15, 2007 4:40 pm
Report this post
Profile WWW
BBWise

Joined: Tue Aug 23, 2005 2:50 pm
Posts: 59
Location: England
Reply with quote
Post Re:
tresni wrote:
I've got bbPyInterWeatherExtravaganza working on the asyncore (actually using asynchat as it's more of a client library where asyncore seems more server orriented). nothing completed at this time but I can attest to the fact that BBSocket does send every bro@m issued to the plugins (and you can respond to them with all kinds of fun things.) Like sending @PluginShow on an @PluginHide (message name wrong but you get the idea)


tresni,
Is this a single threaded approach? I'm currently missing incoming data while it skips off elsewhere in the script.
Could you please post a simple example of a bro@m responder using asyncore?

I was also looking at twised but it seems like overkill for something that should be so trivial :shock:


Mon Jul 16, 2007 11:18 am
Report this post
Profile WWW
Site Admin
User avatar

Joined: Sun Dec 05, 2004 8:59 pm
Posts: 1316
Location: Boise, Idaho
Reply with quote
Post Re: BBSocket 0.0.5
I'll have to dig through my machine at home and see if I can find it. Been a while ;)

_________________
-- Brian


Tue Jul 17, 2007 12:36 am
Report this post
Profile ICQ YIM WWW
BBWise

Joined: Tue Aug 23, 2005 2:50 pm
Posts: 59
Location: England
Reply with quote
Post Re: BBSocket 0.0.5
Thanks muchness.


Tue Jul 17, 2007 12:57 am
Report this post
Profile WWW
Site Admin
User avatar

Joined: Sun Dec 05, 2004 8:59 pm
Posts: 1316
Location: Boise, Idaho
Reply with quote
Post Re: BBSocket 0.0.5
Pasted Source Code

That's the code I have. It works ;-) Beyond that, don't ask me :D

_________________
-- Brian


Tue Jul 17, 2007 5:42 am
Report this post
Profile ICQ YIM WWW
BBWise

Joined: Tue Aug 23, 2005 2:50 pm
Posts: 59
Location: England
Reply with quote
Post Re:
Thanks tresni that worked a treat,

I've also created the same thing using the twisted framework.

sammynono wrote:
I was also looking at twised but it seems like overkill for something that should be so trivial :shock:

I was wrong!
It's far easier to see what's going on in the code.

For the benifit of other experimenters,
It did take me a while to figure out that @BBCore.* bro@ms aren't passed to plugins but that seems very logical :oops:

Code:
# BBSocket-> <-Twisted Framework 0.0.2

from twisted.internet import reactor, protocol
from twisted.protocols.basic import LineReceiver

class BBSocketProtocol(LineReceiver):
    delimiter = "\0"
   
    def connectionMade(self):
        send_Ath_Req = 'AUTHORIZE ' + 'BBSocket-> <-Twisted Framework'
        self.transport.write(send_Ath_Req)       
       
    def lineReceived(self, line):
        print line

class BBSocketClient(protocol.ClientFactory):
   
    protocol = BBSocketProtocol
   
    def clientConnectionFailed(self, connector, reason):
        print "Connection failed - goodbye!"
        reactor.stop()
   
    def clientConnectionLost(self, connector, reason):
        print "Connection lost - goodbye!"
        reactor.stop()

def main():
    reactor.connectTCP("localhost", 25225, BBSocketClient())
    reactor.run()

if __name__ == '__main__' : main()


major edit: changed the protocol class to a lineReceiver with delimiter support :D


Thu Jul 19, 2007 12:19 am
Report this post
Profile WWW
Sponsored Links
Google Adsense


Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 66 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.