+class MultiSwitchboardSession(SwitchboardSessionBase):
+ """ Create one of me to chat to multiple contacts """
+
+ def __init__(self, msncon):
+ """ Automatically creates a new switchboard connection to the server """
+ SwitchboardSessionBase.__init__(self, msncon)
+ self.ident = (self.msncon.ident, repr(self))
+ self.contactCount = 0
+ self.groupchat = None
+ self.connect()
+
+ def failedMessage(self, text):
+ self.groupchat.gotMessage("BOUNCE", text)
+
+ def sendMessage(self, text, noerror=False):
+ """ Used to send a mesage to the groupchat. Can be called immediately
+ after instantiation. """
+ if self.contactCount > 0:
+ SwitchboardSessionBase.sendMessage(self, text, noerror)
+ else:
+ #self.messageBuffer.append((message, noerror))
+ pass # They're sending messages to an empty room. Ignore.
+
+ def inviteUser(self, userHandle):
+ """ Used to invite a contact to the groupchat. Can be called immediately
+ after instantiation. """
+ userHandle = str(userHandle)
+ if self.ready:
+ LogEvent(INFO, self.ident, "immediate")
+ msn.SwitchboardClient.inviteUser(self, userHandle)
+ else:
+ LogEvent(INFO, self.ident, "pending")
+ self.funcBuffer.append(lambda: msn.SwitchboardClient.inviteUser(self, userHandle))
+
+ def gotMessage(self, message):
+ self.groupchat.gotMessage(message.userHandle, message.getMessage())
+
+ def userJoined(self, userHandle, screenName=''):
+ LogEvent(INFO, self.ident)
+ self.contactCount += 1
+ self.groupchat.contactJoined(userHandle)