t.w.p.m.SwitchboardClient(MSNEventBase) : class documentation

Part of twisted.words.protocols.msn View Source View In Hierarchy

This class provides support for clients connecting to a switchboard server.

Switchboard servers are used for conversations with other people on the MSN network. This means that the number of conversations at any given time will be directly proportional to the number of connections to varioius switchboard servers.

MSN makes no distinction between single and group conversations, so any number of users may be invited to join a specific conversation taking place on a switchboard server.

Instance Variable key authorization key, obtained when receiving invitation / requesting switchboard server.
Instance Variable userHandle your user handle (passport)
Instance Variable sessionID unique session ID, used if you are replying to a switchboard invitation
Instance Variable reply set this to 1 in connectionMade or before to signifiy that you are replying to a switchboard invitation.
Method __init__ Undocumented
Method connectionMade Called when a connection is made.
Method connectionLost Called when the connection is shut down.
Method checkMessage hook for detecting any notification type messages (e.g. file transfer)
Method handle_USR Undocumented
Method handle_CAL Undocumented
Method handle_JOI Undocumented
Method handle_IRO Undocumented
Method handle_ANS Undocumented
Method handle_ACK Undocumented
Method handle_NAK Undocumented
Method handle_BYE Undocumented
Method loggedIn called when all login details have been negotiated. Messages can now be sent, or new users invited.
Method gotChattingUsers called after connecting to an existing chat session.
Method userJoined called when a user has joined the conversation.
Method userLeft called when a user has left the conversation.
Method gotMessage called when we receive a message.
Method userTyping called when we receive the special type of message notifying us that a user is typing a message.
Method gotSendRequest called when a contact is trying to send us a file. To accept or reject this transfer see the fileInvitationReply method.
Method inviteUser used to invite a user to the current switchboard server.
Method sendMessage used to send a message.
Method sendTypingNotification No summary
Method sendFileInvitation send an notification that we want to send a file.
Method fileInvitationReply used to reply to a file transfer invitation.
Method sendTransferInfo send information relating to a file transfer session.
Method _sendInit send initial data based on whether we are replying to an invitation or starting one.
Method _newInvitationCookie Undocumented
Method _checkTyping helper method for checkMessage
Method _checkFileInvitation helper method for checkMessage
Method _checkFileResponse helper method for checkMessage
Method _checkFileInfo helper method for checkMessage

Inherited from MSNEventBase:

Method lineReceived Override this for when each line is received.
Method rawDataReceived Override this for when raw data is received.
Method handle_MSG Undocumented
Method handle_UNKNOWN implement me in subclasses if you want to handle unknown events
Method gotBadLine called when a handler notifies me that this line is broken
Method gotError called when the server sends an error which is not in response to a sent command (ie. it has no matching transaction ID)
Method _fireCallback Fire the callback for the given id if one exists and return 1, else return false
Method _nextTransactionID return a usable transaction ID
Method _createIDMapping return a unique transaction ID that is mapped internally to a deferred .. also store arbitrary data if it is needed

Inherited from LineReceiver (via MSNEventBase):

Class Variable delimiter The line-ending delimiter to use. By default this is b'\r\n'.
Class Variable MAX_LENGTH The maximum length of a line to allow (If a sent line is longer than this, the connection is dropped). Default is 16384.
Method clearLineBuffer Clear buffered data.
Method dataReceived Protocol.dataReceived. Translates bytes into lines, and calls lineReceived (or rawDataReceived, depending on mode.)
Method setLineMode Sets the line-mode of this receiver.
Method setRawMode Sets the raw mode of this receiver. Further data received will be sent to rawDataReceived rather than lineReceived.
Method sendLine Sends a line to the other end of the connection.
Method lineLengthExceeded Called when the maximum line length has been reached. Override if it needs to be dealt with in some special way.

Inherited from Protocol (via MSNEventBase, LineReceiver):

Method logPrefix Return a prefix matching the class name, to identify log messages related to this protocol instance.

Inherited from BaseProtocol (via MSNEventBase, LineReceiver, Protocol):

Method makeConnection Make a connection to a transport and a server.

Inherited from _PauseableMixin (via MSNEventBase, LineReceiver):

Method pauseProducing Undocumented
Method resumeProducing Undocumented
Method stopProducing Undocumented
key =
authorization key, obtained when receiving invitation / requesting switchboard server.
userHandle =
your user handle (passport)
sessionID =
unique session ID, used if you are replying to a switchboard invitation
reply =
set this to 1 in connectionMade or before to signifiy that you are replying to a switchboard invitation.
def __init__(self): (source)
Undocumented
def connectionMade(self): (source)
Called when a connection is made.

This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.

def connectionLost(self, reason): (source)
Called when the connection is shut down.

Clear any circular references here, and any external references to this Protocol. The connection has been closed.

def _sendInit(self): (source)
send initial data based on whether we are replying to an invitation or starting one.
def _newInvitationCookie(self): (source)
Undocumented
def _checkTyping(self, message, cTypes): (source)
helper method for checkMessage
def _checkFileInvitation(self, message, info): (source)
helper method for checkMessage
def _checkFileResponse(self, message, info): (source)
helper method for checkMessage
def _checkFileInfo(self, message, info): (source)
helper method for checkMessage
def checkMessage(self, message): (source)
hook for detecting any notification type messages (e.g. file transfer)
def handle_USR(self, params): (source)
Undocumented
def handle_CAL(self, params): (source)
Undocumented
def handle_JOI(self, params): (source)
Undocumented
def handle_IRO(self, params): (source)
Undocumented
def handle_ANS(self, params): (source)
Undocumented
def handle_ACK(self, params): (source)
Undocumented
def handle_NAK(self, params): (source)
Undocumented
def handle_BYE(self, params): (source)
Undocumented
def loggedIn(self): (source)
called when all login details have been negotiated. Messages can now be sent, or new users invited.
def gotChattingUsers(self, users): (source)
called after connecting to an existing chat session.
ParametersusersA dict mapping user handles to screen names (current users taking part in the conversation)
def userJoined(self, userHandle, screenName): (source)
called when a user has joined the conversation.
ParametersuserHandlethe user handle (passport) of the user
screenNamethe screen name of the user
def userLeft(self, userHandle): (source)
called when a user has left the conversation.
ParametersuserHandlethe user handle (passport) of the user.
def gotMessage(self, message): (source)
called when we receive a message.
Parametersmessagethe associated MSNMessage object
def userTyping(self, message): (source)
called when we receive the special type of message notifying us that a user is typing a message.
Parametersmessagethe associated MSNMessage object
def gotSendRequest(self, fileName, fileSize, iCookie, message): (source)
called when a contact is trying to send us a file. To accept or reject this transfer see the fileInvitationReply method.
ParametersfileNamethe name of the file
fileSizethe size of the file
iCookiethe invitation cookie, used so the client can match up your reply with this request.
messagethe MSNMessage object which brought about this invitation (it may contain more information)
def inviteUser(self, userHandle): (source)
used to invite a user to the current switchboard server.
ParametersuserHandlethe user handle (passport) of the desired user.
ReturnsA Deferred, the callback for which will be called when the server notifies us that the user has indeed been invited. The callback argument will be a tuple with 1 element, the sessionID given to the invited user. I'm not sure if this is useful or not.
def sendMessage(self, message): (source)
used to send a message.
Parametersmessagethe corresponding MSNMessage object.
ReturnsDepending on the value of message.ack. If set to MSNMessage.MESSAGE_ACK or MSNMessage.MESSAGE_NACK a Deferred will be returned, the callback for which will be fired when an ACK or NACK is received - the callback argument will be (None,). If set to MSNMessage.MESSAGE_ACK_NONE then the return value is None.
def sendTypingNotification(self): (source)
used to send a typing notification. Upon receiving this message the official client will display a 'user is typing' message to all other users in the chat session for 10 seconds. The official client sends one of these every 5 seconds (I think) as long as you continue to type.
def sendFileInvitation(self, fileName, fileSize): (source)
send an notification that we want to send a file.
ParametersfileNamethe file name
fileSizethe file size
ReturnsA Deferred, the callback of which will be fired when the user responds to this invitation with an appropriate message. The callback argument will be a tuple with 3 elements, the first being 1 or 0 depending on whether they accepted the transfer (1=yes, 0=no), the second being an invitation cookie to identify your follow-up responses and the third being the message 'info' which is a dict of information they sent in their reply (this doesn't really need to be used). If you wish to proceed with the transfer see the sendTransferInfo method.
def fileInvitationReply(self, iCookie, accept=1): (source)
used to reply to a file transfer invitation.
ParametersiCookiethe invitation cookie of the initial invitation
acceptwhether or not you accept this transfer, 1 = yes, 0 = no, default = 1.
ReturnsA Deferred, the callback for which will be fired when the user responds with the transfer information. The callback argument will be a tuple with 5 elements, whether or not they wish to proceed with the transfer (1=yes, 0=no), their ip, the port, the authentication cookie (see FileReceive/FileSend) and the message info (dict) (in case they send extra header-like info like Internal-IP, this doesn't necessarily need to be used). If you wish to proceed with the transfer see FileReceive.
def sendTransferInfo(self, accept, iCookie, authCookie, ip, port): (source)
send information relating to a file transfer session.
Parametersacceptwhether or not to go ahead with the transfer (1=yes, 0=no)
iCookiethe invitation cookie of previous replies relating to this transfer
authCookiethe authentication cookie obtained from an FileSend instance
ipyour ip
portthe port on which an FileSend protocol is listening.
API Documentation for Twisted, generated by pydoctor at 2013-04-03 11:20:05.