Public Member Functions | |
| def | __init__ |
| Default constructor. | |
| def | addBuddy |
| def | createRoom |
| def | destroyRoom |
| def | disconnectUser |
| def | dispatchPublicMessage |
| def | dispatchPrivateMessage |
| def | getCurrentZone |
| def | getCurrentRoom |
| def | getDatabaseManager |
| def | getGuestName |
| def | getSecretKey |
| def | getTimer |
| def | getUserById |
| def | getUserByChannel |
| def | getZone |
| def | joinRoom |
| def | leaveRoom |
| def | loginUser |
| def | logoutUser |
| def | md5 |
| def | sendGenericMessage |
| def | removeBuddy |
| def | removeUser |
| def | requestAddBuddyPermission |
| def | sendBuddyListUpdate |
| def | sendMail |
| def | sendResponse |
| def | sendRoomList |
| def | setBuddyVariables |
| def | setBuddyBlockStatus |
| def | setRoomVariables |
| def | setUserVariables |
| def | switchSpectator |
| def | trace |
| def mainLib::_Server::addBuddy | ( | self, | ||
| buddyName, | ||||
| user | ||||
| ) |
Add a buddy to a user's buddy list
| buddyName | the name of the buddy | |
| user | the buddy list owner |
| def mainLib::_Server::createRoom | ( | self, | ||
| paramObj, | ||||
user = None, |
||||
roomVars = None, |
||||
varsOwner = None, |
||||
setOwnership = False, |
||||
sendUpdate = True, |
||||
broadcast = True | ||||
| ) |
Dynamically create a room
| paramObj | a dictionary with room properties | |
| user | the creator (None by default == owned by the server itself) | |
| roomVars | a list of roomVars to set (by default = None) | |
| varsOwner | the owner of the room variables being created/modified | |
| setOwnership | the roomVars setOwnership flag | |
| sendUpdate | send default update to clients | |
| broadCast | broadcast internal event |
| def mainLib::_Server::destroyRoom | ( | self, | ||
| zone, | ||||
| roomId | ||||
| ) |
Destroy a server room
| zone | the zone object | |
| roomId | the id of the room to destroy |
| def mainLib::_Server::disconnectUser | ( | self, | ||
| user | ||||
| ) |
Disconnect a user
| user | the user to be disconnected |
| def mainLib::_Server::dispatchPublicMessage | ( | self, | ||
| message, | ||||
| room, | ||||
| user | ||||
| ) |
Dispatches a public message (after a "pubMsg" internal event)
| message | the message | |
| room | the target room | |
| user | the sender user |
| def mainLib::_Server::dispatchPrivateMessage | ( | self, | ||
| message, | ||||
| room, | ||||
| sender, | ||||
| recipient | ||||
| ) |
Dispatches a private message (after a "privMsg" internal event)
| message | the message | |
| room | the target room | |
| sender | the sender user | |
| recipient | the recipient user |
| def mainLib::_Server::getCurrentZone | ( | self | ) |
Get the current extensions zone
| def mainLib::_Server::getCurrentRoom | ( | self | ) |
Get the room to which the extension is attached to ( note: this is valid only for Room-Level extensions )
| def mainLib::_Server::getDatabaseManager | ( | self, | ||
zoneName = None | ||||
| ) |
Get the database manager object (if configured in the current Zone)
( see more details in the javadoc -> DbManager Class )
| def mainLib::_Server::getGuestName | ( | self | ) |
Get a guest user name
returns an auto-generated guest user name in the form guest_x where x is a progressive integer.
| def mainLib::_Server::getSecretKey | ( | self, | ||
| channel | ||||
| ) |
Get the user/channel random key
This key is unique for each user session and it used to perform a secure login. You learn more about this in the tutorial at chapter 8.9 of the documentation
| def mainLib::_Server::getTimer | ( | self | ) |
Return current time in milliseconds
| def mainLib::_Server::getUserById | ( | self, | ||
| uid | ||||
| ) |
Get a user from its user id
| def mainLib::_Server::getUserByChannel | ( | self, | ||
| channel | ||||
| ) |
Get a user from its socket channel
| def mainLib::_Server::getZone | ( | self, | ||
| zoneName | ||||
| ) |
Get a Zone object from its name
| def mainLib::_Server::joinRoom | ( | self, | ||
| user, | ||||
| currRoomId, | ||||
| leaveRoom, | ||||
| newRoomId, | ||||
pwd = "", |
||||
isSpec = False, |
||||
broadcast = True | ||||
| ) |
Join a Room
| user | the user | |
| currRoomId | the current room in which the user is already joined ( -1 = no room ) | |
| leaveRoom | if True the user will leave the current room | |
| user | newRoomId the room id of the room you want to join | |
| pwd | an optional password, if the room is private | |
| isSpec | True = join as Spectator ( must be a game room ) | |
| broadcast | True = broadcast the event to the users in the target room |
| it.gotoandplay.smartfoxserver.exceptions.JoinException |
| def mainLib::_Server::leaveRoom | ( | self, | ||
| user, | ||||
| roomId, | ||||
broadcastAll = True | ||||
| ) |
Leave a room (for users in two or more rooms at the same time)
Note: it won't work if the user is joined in one room only
| def mainLib::_Server::loginUser | ( | self, | ||
| nick, | ||||
| pwd, | ||||
| chan | ||||
| ) |
Login User
| nick | the user nickname | |
| pwd | the user password (can be empty) | |
| chan | the client SocketChannel |
| it.gotoandplay.smartfoxserver.exceptions.LoginException |
| def mainLib::_Server::logoutUser | ( | self, | ||
| user, | ||||
fireClientEvt = True, |
||||
fireInternalEvt = True | ||||
| ) |
Logout User
| user | the user | |
| fireClientEvt | True = fire event to other clients | |
| fireInternalEvt | True = fire an internal event, so extensions will be notified |
| def mainLib::_Server::md5 | ( | self, | ||
| strValue | ||||
| ) |
Get MD5 hash
| strValue | a string |
| def mainLib::_Server::sendGenericMessage | ( | self, | ||
| msg, | ||||
| sender, | ||||
| recipients | ||||
| ) |
Sends a generic Message
With this method you can send an arbitrary message, for example a modified version of a room list.
Note: The generic message implies that you send also the message header, so a good knowledge of the SFS Xml protocol is required.
| msg | the message | |
| sender | the sender User ( None = the server ) | |
| recipients | a list of recipients |
| def mainLib::_Server::removeBuddy | ( | self, | ||
| buddyName, | ||||
| user | ||||
| ) |
Removes a buddy from a user buddy list
If mutualRemoveBuddy is activated both users will be removed to their respective buddy lists.
| buddyName | the name of the buddy to remove | |
| user | the owner of the buddy list |
| def mainLib::_Server::removeUser | ( | self, | ||
| who | ||||
| ) |
Removes a user from the server, disconnecting him
| who | the user |
| def mainLib::_Server::requestAddBuddyPermission | ( | self, | ||
| sender, | ||||
| targetUserName, | ||||
optionalMessage = None | ||||
| ) |
Requests permission for adding the target user in the sender buddy list.
This is already done by default if the security mode of the buddy list is set to ADVANCED. In most of the cases you wouldn't need to call this method in your extension.
It could be used to implement an off-line permission request system, where the system stores the requests for off-line users in a database and sends the requests as soon as the target user logs in.
| sender | the requester | |
| targetUserName | the name of the target user | |
| optionalMessage | an optional text message for the request. |
| def mainLib::_Server::sendBuddyListUpdate | ( | self, | ||
| user | ||||
| ) |
Send a buddy list update.
Send an update about the specified User to all clients that have him/her in their buddy list.
Normally you don't need to call this method. Updates are sent automatically when needed.
You may need to force an update if you're manipulating the buddy lists without using the regular commands (add, remove, etc...)
| user | the user that should be updated |
| def mainLib::_Server::sendMail | ( | self, | ||
| fromName, | ||||
| to, | ||||
| subject, | ||||
| message | ||||
| ) |
Send an Html formatted email
| fromName | the sender name | |
| to | the recipient email address | |
| subject | the email subject | |
| message | the email html message |
| def mainLib::_Server::sendResponse | ( | self, | ||
| resObj, | ||||
| fromRoom, | ||||
| who, | ||||
| recipientList, | ||||
msgType = "xml" | ||||
| ) |
Send an Extension Response/Message to the client(s)
The resObj object is a dictionary containing any number of properties (strings, numbers, lists, dictionaries) that should be sent to the client(s)
Dictionaries and lists can be nested to create complex data structures, which are supported by xml and json formats. If you use the str format you will need to pass an array of strings.
| resObj | the response object | |
| fromRoom | an optional room id ( -1 if not needed ) | |
| who | the sender ( None if not needed ) | |
| recipientList | a list of recipients | |
| msgType | the type of message -> can be "xml", "json", "str" |
| def mainLib::_Server::sendRoomList | ( | self, | ||
| who | ||||
| ) |
Send Room List
| who | the recipient User |
| def mainLib::_Server::setBuddyVariables | ( | self, | ||
| user, | ||||
| varDict | ||||
| ) |
Set the buddy variables of the specified user.
The variables dictionary should contain all the variables to set, where the key and value are strings
Since version 1.6.0 you can set off-line buddy variables by using a '$' sign as the first character of the variable name.
| user | the User | |
| variables | a map containing the variables to set |
| def mainLib::_Server::setBuddyBlockStatus | ( | self, | ||
| user, | ||||
| buddyName, | ||||
| isBlocked | ||||
| ) |
Blocks / unblocks a buddy in the user's buddy list When the isBlocked flag is set to true the buddy won't be able to send any messages to the user.
| user | the owner of the buddy list | |
| buddyName | the name of the buddy to block / unblock | |
| isBlocked | the status (true == blocked) |
| def mainLib::_Server::setRoomVariables | ( | self, | ||
| room, | ||||
| who, | ||||
| varList, | ||||
setOwnership = True, |
||||
broadcastAll = True | ||||
| ) |
Set Room Variables
For further informations about Room Variables check the examples and tutorials coming with SmartFoxServer PRO
The varList argument is a list of RoomVariable instances
| room | the target Room object | |
| who | the user, owner of the variables ( None = Server ) | |
| varList | a list of variables | |
| setOwnership | if True will change the ownership of the variables to the user passed in the who argument | |
| broadcastAll | if True will send an update to the other clients in the target Room |
| def mainLib::_Server::setUserVariables | ( | self, | ||
| who, | ||||
| varMap, | ||||
broadcastAll = True | ||||
| ) |
Set User Variables
Set one or more User Variables. The varMap argument is a dictionary containing any number of number, string or boolean values.
| who | the target User | |
| varMap | a dictionary of variables | |
| broadcastAll | if True will send an update to the other users in Room |
| def mainLib::_Server::switchSpectator | ( | self, | ||
| user, | ||||
| roomId, | ||||
broadcastAll = True | ||||
| ) |
Switch a spectator into a player, if possible
| user | the user to switch (must be a spectator) | |
| roomId | the Room in which the user is joined (must be a game room) | |
| broadcastAll | if True, sends and update to all other clients in the Room |
| def mainLib::_Server::trace | ( | self, | ||
| msg | ||||
| ) |
Trace a message to the console and AdminTool (if feature is active)
| msg | a text message |
1.5.4