from application.notification import IObserver, NotificationCenter from application.python import Null from sipsimple.account.bonjour import BonjourPresenceState from twisted.internet import reactor from zope.interface import implements from sylk.applications import SylkApplication, ApplicationLogger from sylk.bonjour import BonjourService from sylk.configuration import ServerConfig log = ApplicationLogger.for_package(__package__) def format_identity(identity): if identity.display_name: return u'%s <sip:%s@%s>' % (identity.display_name, identity.uri.user, identity.uri.host) else: return u'sip:%s@%s' % (identity.uri.user, identity.uri.host) class EchoApplication(SylkApplication): def __init__(self): self.bonjour_services = set() def start(self): if ServerConfig.enable_bonjour: application_map = dict((item.split(':')) for item in ServerConfig.application_map) for uri, app in application_map.iteritems(): if app == 'echo':
import logging from application.log import ContextualLogger from sylk.applications import ApplicationLogger from sylk.log import TraceLogger from .configuration import GeneralConfig, JanusConfig __all__ = 'log', 'ConnectionLogger', 'VideoroomLogger' log = ApplicationLogger(__package__) class ConnectionLogger(ContextualLogger): def __init__(self, connection): super(ConnectionLogger, self).__init__(logger=log) self.device_id = connection.device_id self.peer=connection.protocol.peer self.connection = connection def apply_context(self, message): try: account_id = self.connection.devices_map[self.device_id] except KeyError: return '[device {0}/{2}] {1}'.format(self.peer, message, self.device_id) if message != '' else '' else: return '[account {0}/{2}] {1}'.format(account_id, message, self.device_id) if message != '' else ''
import os from application.python import Null from application.notification import IObserver, NotificationCenter from eventlib import proc from sipsimple.account.bonjour import BonjourPresenceState from sipsimple.audio import WavePlayer, WavePlayerError from twisted.internet import reactor from zope.interface import implements from sylk.applications import SylkApplication, ApplicationLogger from sylk.applications.playback.configuration import get_config from sylk.bonjour import BonjourService from sylk.configuration import ServerConfig log = ApplicationLogger.for_package(__package__) class PlaybackApplication(SylkApplication): def start(self): self.bonjour_services = [] if ServerConfig.enable_bonjour: application_map = dict( (item.split(':')) for item in ServerConfig.application_map) for uri, app in application_map.iteritems(): if app == 'playback': config = get_config('%s' % uri) if config is None: continue if os.path.isfile(config.file) and os.access( config.file, os.R_OK):