Hey,<div>my first e-mail on this list, I`m beginning to code with twisted, started after a research about building c10k servers.. (with python)</div><div>I am using this lib, heard it is the best for working with websockets (correct me if you know another)</div>

<div><a href="https://github.com/wulczer/txWebSocket">https://github.com/wulczer/txWebSocket</a></div><div><br></div><div>Well,</div><div>There is what I want to do:</div><div>I have:</div><div><br></div><div><div>    site = WebSocketSite(root)</div>

<div>    site.addChatHandler(&#39;/room<b>1</b>&#39;, Chathandler)</div><div>    reactor.listenTCP(8080, site) </div><div><br></div><div>where</div><div> </div><div>class Chathandler(WebSocketHandler):</div><div>    users = set()</div>

<div>    def __init__(self, transport):</div><div>        WebSocketHandler.__init__(self, transport)</div><div><br></div><div>    def __del__(self):</div><div>        print &#39;Deleting handler&#39;</div><div>        </div>

<div>    def setUsers(self,usr):</div><div>        self.users = usr</div><div><br></div><div>    def frameReceived(self, frame):</div><div>        adr = self.transport.getPeer()</div><div>        print &quot;Msg rcv from: &quot;, adr</div>

<div>        self.sendChat(adr,frame)</div><div><br></div><div>    def connectionMade(self):</div><div>        print &#39;Connected to client.&#39;</div><div>        self.users.add(self)</div><div><br></div><div>    def connectionLost(self, reason):</div>

<div>        print &#39;Lost connection.&#39;</div><div>        if self in self.users:</div><div>            self.users.remove(self)</div><div>        </div><div>    def sendChat(self,fr,msg):</div><div>        for u in self.users:</div>

<div>            u.transport.write(str(fr)+msg)</div><div><br></div><div>My problem is:</div><div>If I do this:</div><div><div>    site = WebSocketSite(root)</div><div>    site.addChatHandler(&#39;/room<b>1</b>&#39;, Chathandler)</div>

<div><div>    site.addChatHandler(&#39;/room<b>2</b>&#39;, Chathandler)</div></div><div>    site.addChatHandler(&#39;/room<b>3</b>&#39;, Chathandler)</div><div>    reactor.listenTCP(8080, site) </div></div><div><br></div>

<div><div>will not work (every room will comunicate with every room), because the users = set() will be globally between the handlers..</div></div><div>If I put on the __init__, every call on /roomX will have your personal set() of users including only themselfs.</div>

<div><br></div><div>I am kind stuck on this, I`m new to websocket and server programming, so I don`t even know if is the best way to code a chatroom server. </div><div>If you read this far ans have any (even it looks that stupid for you), might help right now (:</div>

<div><br></div><div>Thanks,</div><div><br></div>-- <br><b>João Ricardo Mattos e Silva</b><br><br><span style="font-size:x-small">Graduando em Ciência da Computação na Universidade Federal de Santa Catarina<br></span><br>
<b><font face="&#39;courier new&#39;, monospace">Cel: </font></b><font face="&#39;courier new&#39;, monospace">+55 (48) 96190063  |  <b>Skype:</b> jricardomsilva  | <b> Msn: </b><a href="mailto:joaoricardo@globalite.com.br" target="_blank">joaoricardo@globalite.com.br</a></font><br>


</div>