Package HappyChat :: Module HappyChatProtocol :: Class HappyChatDefaultProtocol
[show private | hide private]
[frames | no frames]

Class HappyChatDefaultProtocol

BaseProtocol --+    
               |    
        Protocol --+
                   |
                  HappyChatDefaultProtocol


Default protocol for HappyChat Server.
only 6 commands :
  pong : request a session on the server
  speak : say somethink is the curent room
  nickname : change nickname (not in use)
  roominfo : ask room information (list avatar)
  avatarinfo: ask information about an avatar (list properties)
  quit: disconnect the client properly

Each command is binded to a method of this class prefixed by 'do_'
par exemple : speak command is bind to do_speak method

Method Summary
  connectionLost(self, reason)
Call when a connection is close delete avatar and clean structures
  connectionMade(self)
Call when a new connection is made add a pending information to the world
  dataReceived(self, data)
Call on each query get the command to execute in the raw XML structure the executed action can me a method of this class or a function in a module in the actions package
  do_avatarinfo(self, socket, element)
handle a avatar information from avatar over TCP socket.
  do_nickname(self, socket, element)
handle a nickname change ask by avatar over TCP socket
  do_pong(self, socket, element)
handle a pong request this is the first request ask by avatar client send a session_id.
  do_quit(self, socket, element)
handle a quit request, disconnect the avatar, close the socket and remove avatar from memory
  do_roominfo(self, socket, element)
handle a room information request from avatar over TCP socket
  do_speak(self, socket, element)
handle a speak request from avatar over TCP socket
Avatar getAvatar(self, socket)
Get the default avatar by given socket
tuple of (method, Element). getCommand(self, data)
Get the command of the raw XML structure
socket getSocket(self)
Return the socket of the curent connection
    Inherited from Protocol
  connectionFailed(self)
(Deprecated)
    Inherited from BaseProtocol
  makeConnection(self, transport)
Make a connection to a transport and a server.

Class Variable Summary
    Inherited from Protocol
tuple __implements__ = (<class 'twisted.internet.interfaces.IP...
    Inherited from BaseProtocol
int connected = 0                                                                     
NoneType transport = None                                                                  

Method Details

connectionLost(self, reason)

Call when a connection is close delete avatar and clean structures
Overrides:
twisted.internet.protocol.Protocol.connectionLost

connectionMade(self)

Call when a new connection is made add a pending information to the world
Overrides:
twisted.internet.protocol.BaseProtocol.connectionMade

dataReceived(self, data)

Call on each query get the command to execute in the raw XML structure the executed action can me a method of this class or a function in a module in the actions package
Parameters:
data - raw XML structure take from socket read
           (type=string)
Returns:
None
Overrides:
twisted.internet.protocol.Protocol.dataReceived

do_avatarinfo(self, socket, element)

handle a avatar information from avatar over TCP socket.
Parameters:
element - The element created by parsing the received XML
           (type=Element)
Returns:
None

do_nickname(self, socket, element)

handle a nickname change ask by avatar over TCP socket
Parameters:
element - The element created by parsing the received XML
           (type=Element)
Returns:
None

do_pong(self, socket, element)

handle a pong request this is the first request ask by avatar client send a session_id.
Parameters:
element - The element created by parsing the received XML
           (type=Element)
Returns:
None

do_quit(self, socket, element)

handle a quit request, disconnect the avatar, close the socket and remove avatar from memory
Parameters:
element - The element created by parsing the received XML
           (type=Element)
Returns:
None

do_roominfo(self, socket, element)

handle a room information request from avatar over TCP socket
Parameters:
element - The element created by parsing the received XML
           (type=Element)
Returns:
None

do_speak(self, socket, element)

handle a speak request from avatar over TCP socket
Parameters:
element - The element created by parsing the received XML
           (type=Element)
Returns:
None

getAvatar(self, socket)

Get the default avatar by given socket
Parameters:
socket - socket where data was rode
           (type=socket)
Returns:
Avatar
           (type=Avatar)

getCommand(self, data)

Get the command of the raw XML structure

@return the command to do.
Parameters:
data - XML raw string structure.
           (type=string from a socket read.)
Returns:
tuple of (method, Element).

getSocket(self)

Return the socket of the curent connection
Returns:
Socket
           (type=socket)

Generated by Epydoc 2.1 on Sun Sep 19 21:40:09 2004 http://epydoc.sf.net