Skip to content

Instantly share code, notes, and snippets.

@abhigenie92
Last active April 8, 2016 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhigenie92/19d5ab69bf30b108f031956cee88f220 to your computer and use it in GitHub Desktop.
Save abhigenie92/19d5ab69bf30b108f031956cee88f220 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from twisted.internet.protocol import Protocol, Factory
class AudioEcho(Protocol):
def __init__(self, factory):
self.factory = factory
def connectionMade(self):
print "Connected client:",self
self.factory.echoers.append(self)
def dataReceived(self, data):
for echoer in self.factory.echoers:
if echoer!=self:
print "sent data"
echoer.transport.write(data)
def connectionLost(self, reason):
self.factory.echoers.remove(self)
class AudioEchoFactory(Factory):
def __init__(self,server_room):
self.echoers = []
self.server_room=server_room
def buildProtocol(self, addr):
return AudioEcho(self)
Server log:
2016-04-09 01:13:52+0530 [-] Connected client: <stroke_protocol.StrokeEcho instance at 0x00000000050C7108>
2016-04-09 01:13:52+0530 [-] Connected client: <audio_protocol.AudioEcho instance at 0x00000000050D4448>
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:52+0530 [-] sent data
2016-04-09 01:13:53+0530 [-] sent data
2016-04-09 01:13:53+0530 [-] sent data
2016-04-09 01:13:53+0530 [-] sent data
2016-04-09 01:13:53+0530 [-] sent data
2016-04-09 01:13:53+0530 [-] sent data
2016-04-09 01:13:53+0530 [-] sent data
2016-04-09 01:13:53+0530 [-] sent data
2016-04-09 01:13:53+0530 [-] sent data
2016-04-09 01:13:53+0530 [-] sent data
2016-04-09 01:13:53+0530 [-] sent data
2016-04-09 01:13:53+0530 [-] Audio client disconnected: <audio_protocol.AudioEcho instance at 0x00000000050D4448>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment