Add audio forwarding to crosslink

This commit is contained in:
Maurizio Porrato 2010-08-23 00:35:22 +02:00
parent aaeca932b8
commit 9540837e7a
1 changed files with 38 additions and 3 deletions

View File

@ -10,9 +10,15 @@ from frn.user import FRNUser
from twisted.python import log
clients = []
talking = None
class FRNCrosslinkClient(FRNClient):
def connectionMade(self):
self.txOk = False
self.txReq = False
FRNClient.connectionMade(self)
def getClientName(self, client_id):
if self.clientsById.has_key(client_id):
return self.clientsById[client_id]['on']
@ -20,6 +26,7 @@ class FRNCrosslinkClient(FRNClient):
return client_id
def textMessageReceived(self, client, message, target):
global clients
if target == 'A':
for _, _, _, factory in clients:
if factory != self.factory:
@ -34,17 +41,45 @@ class FRNCrosslinkClient(FRNClient):
for c in factory.connection.clients:
cl.append("(%s)" % (c['on'],))
reply = ' '.join(cl)
factory.connection.sendTextMessage(client, reply)
self.sendTextMessage(client, reply)
def decodeTX(self, my_id):
log.msg("Got TX ack for %s" % self.user.ON)
self.txOk = True
def stopTransmission(self):
FRNClient.stopTransmission(self)
log.msg("Stopped playback.")
log.msg("Stopped TX on %s" % self.user.ON)
def goIdle(self):
global talking
self.txReq = False
self.txOk = False
talking = None
self.stopTransmission()
def audioFrameReceived(self, from_id, frames):
global clients, talking
if talking is None or talking == self:
talking = self
for _, _, _, factory in clients:
conn = factory.connection
if conn != self:
if conn.txOk:
conn.txReq = False
conn.sendAudioFrame(frames)
conn.busyTimer.reset(5.0)
else:
if not conn.txReq:
log.msg("Requesting TX for %s" % conn.user.ON)
conn.startTransmission()
conn.txReq = True
conn.busyTimer = conn.factory.reactor.callLater(
7.0, conn.goIdle)
self.pong()
def loginResponse(self, info):
log.msg("Login: %s" % info['al'])
log.msg("%s login: %s" % (self.user.ON, info['al']))
def clientsListUpdated(self, clients):
self.clients = clients