Beispiel #1
0
    def __init__(self,
                 name,
                 component_main,
                 keep_alive_always=False,
                 keep_alive_when_outgoing=False):
        self.name = name
        self.component_main = component_main
        self.keep_alive_always = keep_alive_always
        self.keep_alive_when_outgoing = keep_alive_when_outgoing

        self.to_component = Queue()
        self.from_component = Queue()

        self.proc = None
        self.proc_counter = 0
        self.kickstart()

        thread = threading.Thread(target=self.main_loop)
        thread.setDaemon(True)
        thread.start()

        if self.keep_alive_always or self.keep_alive_when_outgoing:
            thread = threading.Thread(target=self.keepalive_loop)
            thread.setDaemon(True)
            thread.start()

        signal_component.connect(self.receive, weak=False)
Beispiel #2
0
    def __init__(self, name, component_main, keep_alive_always=False, keep_alive_when_outgoing=False):
        self.name = name
        self.component_main = component_main
        self.keep_alive_always = keep_alive_always
        self.keep_alive_when_outgoing = keep_alive_when_outgoing

        self.to_component = Queue()
        self.from_component = Queue()

        self.proc = None
        self.proc_counter = 0
        self.kickstart()

        thread = threading.Thread(target=self.main_loop)
        thread.setDaemon(True)
        thread.start()

        if self.keep_alive_always or self.keep_alive_when_outgoing:
            thread = threading.Thread(target=self.keepalive_loop)
            thread.setDaemon(True)
            thread.start()

        signal_component.connect(self.receive, weak=False)
Beispiel #3
0
# Copyright 2010 Alon Zakai ('kripken'). All rights reserved.
# This file is part of Syntensity/the Intensity Engine, an open source project. See COPYING.txt for licensing.

from intensity.base import *
from intensity.logging import *
from intensity.world import restart_map
from intensity.signals import signal_component


def receive(sender, **kwargs):
    component_id = kwargs['component_id']
    data = kwargs['data']

    try:
        if component_id == 'MapControl':
            parts = data.split('|')
            command = parts[0]
            params = '|'.join(parts[1:])
            if command == 'restart':
                main_actionqueue.add_action(restart_map)
    except Exception, e:
        log(logging.ERROR, "Error in MapControl component: " + str(e))

    return ''


signal_component.connect(receive, weak=False)
Beispiel #4
0
    def act():
        try:
            if component_id == 'VLC':
                parts = data.split('|')
                command = parts[0]
                params = '|'.join(parts[1:])
                if command == 'play':
                    if params != '':
                        media=instance.media_new(params)
                        player.set_media(media)
                        player.play()
                    else:
                        player.stop()
                elif command == 'setvolume':
                    instance.audio_set_volume(int(params))
        except Exception, e:
            log(logging.ERROR, "Error in VLC component: " + str(e))

    actionqueue.add_action(act)

    return ''

signal_component.connect(receive, weak=False)

# Examples:
#receive(None, **{ 'component_id': 'VLC', 'data': 'play|http://scfire-mtc-aa02.stream.aol.com:80/stream/1022' })
#receive(None, **{ 'component_id': 'VLC', 'data': 'setvolume|10' })
#receive(None, **{ 'component_id': 'VLC', 'data': 'play|' }) # Stop playing