ChatAppDev
description: 聊天即时通讯: 支持组、好友列表、隐私管理等
Chat app for Paraworld
| Title |
Chat app for Paraworld |
| Author(s) |
WangTian? , original template by LiXizhi |
| Date |
2008/1/9, Added Summon mode 2008.7.18 lxz |
| File |
script/kids/3DMapSystemUI/Chat/app_main.lua |
Description
chatting via jabber
Summon Mode
More information, please see
NPL.load("(gl)script/kids/3DMapSystemUI/Chat/SummonMode.lua");
-- activate summon mode
Map3DSystem.App.Commands.Call("Profile.Chat.Summon");
-- block a summoned agent
Map3DSystem.App.Commands.Call("Profile.Chat.BlockAgent", {JID = JID});
Sample Code
NPL.load("(gl)script/kids/3DMapSystemUI/Chat/app_main.lua");
Member Functions
Map3DSystem.App.Chat.OnConnection
requires
create class
commonlib.setfield("Map3DSystem.App.Chat", {});
event handlers
OnConnection? method is the obvious point to place your UI (menus, mainbars, tool buttons) through which the user will communicate to the app.
This method is also the place to put your validation code if you are licensing the add-in. You would normally do this before putting up the UI.
If the user is not a valid user, you would not want to put the UI into the IDE.
- param app : the object representing the current application in the IDE.
- param connectMode : type of Map3DSystem? .App.ConnectMode.
syntax
function Map3DSystem.App.Chat.OnConnection(app, connectMode)
parameters
| app |
the object representing the current application in the IDE. |
| connectMode |
|
Map3DSystem.App.Chat.OnDisconnection
Receives notification that the Add-in is being unloaded.
syntax
function Map3DSystem.App.Chat.OnDisconnection(app, disconnectMode)
parameters
Map3DSystem.App.Chat.OnQueryStatus
This is called when the command's availability is updated
When the user clicks a command (menu or mainbar button), the
QueryStatus? event is fired.
The
QueryStatus? event returns the current status of the specified named command, whether it is enabled, disabled,
or hidden in the
CommandStatus? parameter, which is passed to the msg by reference (or returned in the event handler).
- param commandName : The name of the command to determine state for. Usually in the string format "Category.SubCate.Name".
- param statusWanted : what status of the command is queried. it is of type Map3DSystem? .App.CommandStatusWanted
- return __ : returns according to statusWanted. it may return an integer by adding values in Map3DSystem? .App.CommandStatus.
syntax
function Map3DSystem.App.Chat.OnQueryStatus(app, commandName, statusWanted)
parameters
| app |
|
| commandName |
The name of the command to determine state for. Usually in the string format "Category.SubCate.Name". |
| statusWanted |
|
| return |
returns according to statusWanted. it may return an integer by adding values in Map3DSystem? .App.CommandStatus. |
Map3DSystem.App.Chat.OnExec
This is called when the command is invoked.The Exec is fired after the
QueryStatus? event is fired, assuming that the return to the statusOption parameter of
QueryStatus? is supported and enabled.
This is the event where you place the actual code for handling the response to the user click on the command.
- param commandName : The name of the command to determine state for. Usually in the string format "Category.SubCate.Name".
syntax
function Map3DSystem.App.Chat.OnExec(app, commandName, params)
parameters
| app |
|
| commandName |
The name of the command to determine state for. Usually in the string format "Category.SubCate.Name". |
| params |
|
Map3DSystem.App.Chat.OnRenderBox
Change and render the 3D world with mcml data that is usually retrieved from the current user's profile page for this application.
syntax
function Map3DSystem.App.Chat.OnRenderBox(mcmlData)
parameters
Map3DSystem.App.Chat.Navigate
called when the user wants to nagivate to the 3D world location relavent to this application
syntax
function Map3DSystem.App.Chat.Navigate()
Map3DSystem.App.Chat.GotoHomepage
called when user clicks to check out the homepage of this application. Homepage usually includes:
developer info, support, developer worlds information, app global news, app updates, all community user rating, active users, trade, currency transfer, etc.
syntax
function Map3DSystem.App.Chat.GotoHomepage()
Map3DSystem.App.Chat.DoQuickAction
called when user clicks the quick action for this application.
syntax
function Map3DSystem.App.Chat.DoQuickAction()
Map3DSystem.App.Chat.OnDeactivateDesktop
syntax
function Map3DSystem.App.Chat.OnDeactivateDesktop()
Map3DSystem.App.Chat.MSGProc
client world database function helpers.
all related messages
APPS can be invoked in many ways:
Through app Manager
mainbar or menu command or buttons
Command Line
3D World installed apps
syntax
function Map3DSystem.App.Chat.MSGProc(window, msg)
parameters
Lobby BBS channel manager
| Title |
Lobby BBS channel manager |
| Author(s) |
WangTian? |
| Date |
2008/6/24, Doc requirement added LiXizhi. 2008.7.20 |
| File |
script/kids/3DMapSystemUI/Chat/ChannelManager.lua |
Description
Message format
{
uid = user id,
date = send date,
channelName = channel name that this message belongs to,
channelColor = text color, [optional]
text = pure or mcml text,
name = fullname of the user sending the message.
JID = JID of the user sending the message.
}
Please note that in the remote database, we only store three fields {uid, date, content}
Hence, uid, date are read exactly as in the remote database.
channelColor and channelName are added locally according to local settings when a message is retrieved.
text, name, JID are stored as
NPL table in content column. Whenever we received the content field from the server,
we will decide if it is xml (pure text) or a serialized
NPL table string(begins with '{'). If it is table, all table fields
are extracted to the message.
Sending message
Usually when we send messages, we usually send a serialized table string containing {text, name, JID}, such as
{
uid,
channelName,
content = commonlib.serialize_compact({text, name, JID});
}
The text length is limited to 256 characters.
Displaying message in chat window
we will reconstruct an mcml string from available message fields to display a given message. the reconstruction is as below.
[{msg.channelName}]
:{msg.text}
We will display 8 messsages at a time in a screen.
Getting latest messages
the way client getting messages from server is based on polling. the polling logic is below
- If lastUpdateTime==nil, immediately fetch from the server the lastest 50 messages.
- If we have just send out a text, immediately fetch from the server the lastest messages since the lastUpdateTime
we will prevent entering text again until either the last update returned or some serverTimeOut(10 s) is passed.
- If we have not been sending messages then
if chat window is enabled then
if the last fetched messages are Not empty
update from server again activeUpdateInterval( 1 seconds) after the last fetching result is available or some serverTimeOut(10 s) is passed.
else
update from server again after activeEmptyUpdateInterval( 5 seconds) after the last fetching result is available or some serverTimeOut(10 s) is passed.
end
else
if the last fetched messages are Not empty
update from server again passiveUpdateInterval( 5 seconds) after the last fetching result is available or some serverTimeOut(10 s) is passed.
else
update from server again after passiveEmptyUpdateInterval( 10 seconds) after the last fetching result is available or some serverTimeOut(10 s) is passed.
end
end
end
Getting already fetched messages
Call the following method to retrieve already fetched messages. It can be called as many times by any other applications.
such as the summon mode. It only returns from the local memory.
local msgs = Map3DSystem.App.Chat.ChannelManager.GetFetchedMessages({
channel = nil, if nil it means from all channels,
afterDate = nil, if nil it means the latest
pageSize = 50, return the latest number of message after afterDate
})
Sample Code
NPL.load("(gl)script/kids/3DMapSystemUI/Chat/ChannelManager.lua");
Map3DSystem.App.Chat.ChannelManager.AddChannel("Channel_1")
Member Functions
ChannelManager.Init
create class
local
ChannelManager? = {};
commonlib.setfield("Map3DSystem.App.Chat.ChannelManager",
ChannelManager? );
all channel messages are stored in the channels table
each entry with a treeview node inside residing all the messages in that channel
treeview can use that node as a root node to show the messages directly
ChannelManager? .channels = {};
text color of the default channel messages
TextColors? = {
["Public"] = "FAEBD7",
["Help"] = "ADD8E6",
["World"] = "32CD32",
["Chat"] = "FFC0CB",
};
init the channels and the message time
syntax
function ChannelManager.Init()
ChannelManager.OnUISetup
init the message on UISetup
syntax
function ChannelManager.OnUISetup()
ChannelManager.AddChannel
add a channel to manager
syntax
function ChannelManager.AddChannel(channelName, channelText)
parameters
ChannelManager.RemoveChannel
remove a channel from manager
syntax
function ChannelManager.RemoveChannel(channelName)
parameters
ChannelManager.GetChannelRootTreeNode
get the channel root treenode, it containing all the message information
NOTE: this node is the root node of channel manager, all channels post information to this node
syntax
function ChannelManager.GetChannelRootTreeNode()
ChannelManager.ChangeFocusChannel
change focus to channel
syntax
function ChannelManager.ChangeFocusChannel(channelName)
parameters
ChannelManager.GetFocusChannelText
get focus channel text
syntax
function ChannelManager.GetFocusChannelText()
ChannelManager.AppendJabberChatMessage
append the jabber chat message to the channel root node
syntax
function ChannelManager.AppendJabberChatMessage(JID, subject, body)
parameters
ChannelManager.UpdateMessages
common show update interval
local isProcessing = false; -- is web service processing
CommonShowUpdateInterval? = 500; -- in milliseconds
update 0.1 second after text sent
TextSentUpdateLatency? = 100;
local _elapsedtime = 0;
local _currentTime = 0; -- only for deltatime
get all messages from all channels
syntax
function ChannelManager.UpdateMessages()
ChannelManager.PostMessage
post message to the current focus channel
- param content : the message content
syntax
function ChannelManager.PostMessage(contentStr)
parameters
chat window
| Title |
chat window |
| Author(s) |
WangTian? |
| Date |
2007/10/14 |
| File |
script/kids/3DMapSystemUI/Chat/ChatWnd.lua |
Description
Sample Code
NPL.load("(gl)script/kids/3DMapSystemUI/Chat/ChatWnd.lua");
Member Functions
Map3DSystem.UI.Chat.ChatWnd:new
constructor
syntax
function Map3DSystem.UI.Chat.ChatWnd:new(o)
parameters
Map3DSystem.UI.Chat.ChatWnd:show
- param bShow : boolean to show or hide. if nil, it will toggle current setting.
syntax
function Map3DSystem.UI.Chat.ChatWnd:show(bShow)
parameters
| bShow |
boolean to show or hide. if nil, it will toggle current setting. |
Map3DSystem.UI.Chat.ChatWnd:InitUI
init the
ChatWnd? UI
syntax
function Map3DSystem.UI.Chat.ChatWnd:InitUI(parent)
parameters
Map3DSystem.UI.Chat.ChatWnd.DrawContactNodeHandler
chat window chatting history treeview owner draw function
syntax
function Map3DSystem.UI.Chat.ChatWnd.DrawContactNodeHandler(_parent, treeNode)
parameters
Map3DSystem.UI.Chat.ChatWnd.MSGProc
chat window message procedure
syntax
function Map3DSystem.UI.Chat.ChatWnd.MSGProc(window, msg)
parameters
Map3DSystem.UI.Chat.ChatWnd.GetWindowFrame
get the window frame according to the user JID
syntax
function Map3DSystem.UI.Chat.ChatWnd.GetWindowFrame(sJID)
parameters
Map3DSystem.UI.Chat.ChatWnd.ShowUI
show ui function of the chat window
- param bShow : true or false
- param parentUI : parent UI contain object
- param parentWindow : parent os window object
syntax
function Map3DSystem.UI.Chat.ChatWnd.ShowUI(bShow, parentUI, parentWindow)
parameters
| bShow |
true or false |
| parentUI |
|
| parentWindow |
parent os window object |
Map3DSystem.UI.Chat.ChatWnd.OnCloseWindow
close callback function of the chat window
syntax
function Map3DSystem.UI.Chat.ChatWnd.OnCloseWindow(sJID)
parameters
Map3DSystem.UI.Chat.ChatWnd:OnClose
close the chat windows
syntax
function Map3DSystem.UI.Chat.ChatWnd:OnClose()
Map3DSystem.UI.Chat.ChatWnd:AddTextToChatHistory
add a line of text to the chat history
- param from : the name of the user
- param subject : nil
- param body : the message body
syntax
function Map3DSystem.UI.Chat.ChatWnd:AddTextToChatHistory(from, subject, body)
parameters
| from |
the name of the user |
| subject |
|
| body |
the message body |
Map3DSystem.UI.Chat.ChatWnd:OnReceiveMessage
called when received a message from server
- param from : the name of the user
- param subject : nil
- param body : the message body
syntax
function Map3DSystem.UI.Chat.ChatWnd:OnReceiveMessage(from, subject, body)
parameters
| from |
the name of the user |
| subject |
|
| body |
the message body |
Map3DSystem.UI.Chat.ChatWnd:SendChatMessage
called to send a message
- param to : JID
- param body : the message body
syntax
function Map3DSystem.UI.Chat.ChatWnd:SendChatMessage(to, body)
parameters
Map3DSystem.UI.Chat.ChatWnd.UpdateContactStatus
update the contact status of the given user
- param sJID : given user JID
- param status : online status
- param personalMSG : personal message
syntax
function Map3DSystem.UI.Chat.ChatWnd.UpdateContactStatus(sJID, status, personalMSG)
parameters
| sJID |
given user JID |
| status |
|
| personalMSG |
personal message |
Map3DSystem.UI.Chat.ChatWnd.GetWindowFrameDocument
get the document window UI object of the given user
- param sJID : given user JID
syntax
function Map3DSystem.UI.Chat.ChatWnd.GetWindowFrameDocument(sJID)
parameters
Map3DSystem.UI.Chat.ChatWnd.OnSendMessage_static
static function
send message in the textBox of the chat window
syntax
function Map3DSystem.UI.Chat.ChatWnd.OnSendMessage_static(sJID)
parameters
Chat contact window user interface
| Title |
Chat contact window user interface |
| Author(s) |
WangTian? |
| Date |
2008/5/27 |
| File |
script/kids/3DMapSystemUI/Chat/ChatWnd2.lua |
Description
Sample Code
NPL.load("(gl)script/kids/3DMapSystemUI/Chat/ChatWnd2.lua");
local chatwnd = Map3DSystem.App.Chat.ChatWnd:CreateGetWnd({"andy2@pala5.cn"});
chatwnd:ShowMainWnd(true);
Member Functions
Map3DSystem.App.Chat.ChatWnd:CreateGetWnd
get the
ChatWnd? by its JID list. if the
ChatWnd? of the given JIDs list is not created. it will create a new one and return.
- param JIDs : e.x. {"andy2@pala5.cn", "leio@pala5.cn", "lixizhi@pala5.cn", "Clayman@pala5.cn", ...} create ChatWnd? object
syntax
function Map3DSystem.App.Chat.ChatWnd:CreateGetWnd(JIDs)
parameters
Map3DSystem.App.Chat.ChatWnd:ShowMainWnd
Show the Chat window
syntax
function Map3DSystem.App.Chat.ChatWnd:ShowMainWnd(bShow)
parameters
Map3DSystem.App.Chat.ChatWnd:GetTextAndIcon
get the text and icon according to
ChatWnd? JID list
- return text :, icon, shortText: string
syntax
function Map3DSystem.App.Chat.ChatWnd:GetTextAndIcon()
parameters
| return |
, icon, shortText: string |
Map3DSystem.App.Chat.ChatWnd:Update
update the UI
syntax
function Map3DSystem.App.Chat.ChatWnd:Update()
Map3DSystem.App.Chat.ChatWnd:RecvMSG
recv message
- param JID :
- param subject :
- param body :
syntax
function Map3DSystem.App.Chat.ChatWnd:RecvMSG(JID, subject, body)
parameters
Map3DSystem.App.Chat.ChatWnd:SendMSG
send message
syntax
function Map3DSystem.App.Chat.ChatWnd:SendMSG()
Map3DSystem.App.Chat.ChatWnd:AppendMSG
append the message to conversation treeview and update
syntax
function Map3DSystem.App.Chat.ChatWnd:AppendMSG(JID, body)
parameters
Map3DSystem.App.Chat.ChatWnd.OnToggleChatTab
click on the chat tab
syntax
function Map3DSystem.App.Chat.ChatWnd.OnToggleChatTab(ID)
parameters
Map3DSystem.App.Chat.ChatWnd.GenerateID
generate a unique ID of this chat window using the JIDs
syntax
function Map3DSystem.App.Chat.ChatWnd.GenerateID(JIDs)
parameters
Map3DSystem.App.Chat.ChatWnd.GetChatWndByID
get the chat window using ID
syntax
function Map3DSystem.App.Chat.ChatWnd.GetChatWndByID(ID)
parameters
Map3DSystem.App.Chat.ChatWnd.MSGProc
Message Processor of Chat chat window control
syntax
function Map3DSystem.App.Chat.ChatWnd.MSGProc(window, msg)
parameters
Map3DSystem.App.Chat.ChatWnd.Show
show Chat
ChatWnd? in the parent window
- param bShow : boolean to show or hide. if nil, it will toggle current setting.
- param __ :_parent: parent window inside which the content is displayed. it can be nil.
- param parentWindow : parent os window object, parent window for sending messages
syntax
function Map3DSystem.App.Chat.ChatWnd.Show(bShow, _parent, parentWindow)
parameters
| bShow |
boolean to show or hide. if nil, it will toggle current setting. |
| parent |
|
| parentWindow |
parent os window object, parent window for sending messages |
Map3DSystem.App.Chat.ChatWnd.OnInputTextChange
monitor the keychange, enter to send message
syntax
function Map3DSystem.App.Chat.ChatWnd.OnInputTextChange(ChatWndID)
parameters
Chat system contacts bar
| Title |
Chat system contacts bar |
| Author(s) |
WangTian? |
| Date |
2008/8/13 |
| File |
script/kids/3DMapSystemUI/Chat/ContactsBar.lua |
Description
contacts bar is a container shown on the right bottom of the screen, right above the status bar.
Each item in the contacts bar is an icon represents a user in the chat contact list. Each icon
is accociated with a chat window which is triggered by the user or receive a message.
Chat window can be minimized to the coresponding icon. Online status of the contact is shown on
the right bottom 1/4 corner over the icon. If new message received, and chat window is minimized(not visible),
new messages are shown with a bubble.
Sample Code
NPL.load("(gl)script/kids/3DMapSystemUI/Chat/ContactsBar.lua");
Member Functions
ContactsBar.AddContact
if(not
Map3DSystem? .App.Chat.ContactsBar) then
Map3DSystem? .App.Chat.ContactsBar = {}; end
local
ContactsBar? = {};
Map3DSystem? .App.Chat.ContactsBar =
ContactsBar? ;
ContactsBarNodes? =
TreeNode? :new({Text = "contactsbar", Name = "contactsbar"});
add a status bar task.
- param task : { name = "Chat1", icon = "optional icon, usually has it", text = "this is optional", tooltip = "some text", commandName = "", }
- param priority : number Priority defines the position of the given command in the status bar. Higher priority shown on the right. For those items with the same priority, the more recent added has lower priority which shows on the left. Here are some default priorities for official applications:
- ChatWindow?
- 3, OfficalAppStatus? : 8, DefaultPriority? : 5
syntax
function ContactsBar.AddContact(contact, priority)
parameters
ContactsBar.RemoveContact
remove contact icon from the contacts bar
- param contactName : the task to be removed from the contacts bar
syntax
function ContactsBar.RemoveContact(contactName)
parameters
| contactName |
the task to be removed from the contacts bar |
ContactsBar.ClearContacts
remove all tasks in contacts bar
syntax
function ContactsBar.ClearContacts()
ContactsBar.Refresh
refresh the contacts bar with the UI parent container
syntax
function ContactsBar.Refresh(_parent)
parameters
history window
| Title |
history window |
| Author(s) |
WangTian? |
| Date |
2007/10/14 |
| File |
script/kids/3DMapSystemUI/Chat/HistoryWnd.lua |
Description
Sample Code
NPL.load("(gl)script/kids/3DMapSystemUI/Chat/HistoryWnd.lua");
Member Functions
Map3DSystem.UI.Chat.HistoryWnd.ShowUI
- param bShow : show or hide the panel
- param parentUI : parent container inside which the content is displayed. it can be nil.
- param parentWindow : parent window for sending messages
syntax
function Map3DSystem.UI.Chat.HistoryWnd.ShowUI(bShow, parentUI, parentWindow)
parameters
| bShow |
show or hide the panel |
| parentUI |
|
| parentWindow |
parent window for sending messages |
Lobby BBS channel page
| Title |
Lobby BBS channel page |
| Author(s) |
WangTian? |
| Date |
2008/6/23 |
| File |
script/kids/3DMapSystemUI/Chat/LobbyBBSChannelPage.lua |
Description
Sample Code
NPL.load("(gl)script/kids/3DMapSystemUI/Chat/LobbyBBSChannelPage.lua");
Map3DSystem.App.Chat.LobbyBBSChannelPage.Show()
Member Functions
LobbyBBSChannelPage.OnInit
create class
local
LobbyBBSChannelPage? = {};
commonlib.setfield("Map3DSystem.App.Chat.LobbyBBSChannelPage",
LobbyBBSChannelPage? );
text line height of a message. some fixed line height.
local
FixedLineHeight? = 18;
on init show the current avatar in pe:avatar
syntax
function LobbyBBSChannelPage.OnInit()
LobbyBBSChannelPage.OnClose
open using external system web browser, such as ie
syntax
function LobbyBBSChannelPage.OnClose()
LobbyBBSChannelPage.DoFramemove
update 0.05 second after first shown
local _elapsedtime = 0;
FirstShowUpdateLatency? = 0.05;
on init show the current avatar in pe:avatar
syntax
function LobbyBBSChannelPage.DoFramemove()
LobbyBBSChannelPage.Show
show the lobby BBS channel page
syntax
function LobbyBBSChannelPage.Show(bShow)
parameters
LobbyBBSChannelPage.ShowBBS
- param params : a table containing
syntax
function LobbyBBSChannelPage.ShowBBS(bShow, _parent, params)
parameters
| bShow |
|
| parent |
|
| params |
a table containing |
Map3DSystem.App.Chat.LobbyBBSChannelPage.ChatOption
onclick the four control button in the channel page
syntax
function Map3DSystem.App.Chat.LobbyBBSChannelPage.ChatOption()
new chat system for 3D Map system
| Title |
new chat system for 3D Map system |
| Author(s) |
WangTian? |
| Date |
2008/5/27 |
| File |
script/kids/3DMapSystemUI/Chat/Main.lua |
Description
Chat system main
Chat system is based on the Jabber client and works as a part of the paraworld online experience.
OneTimeInit? funciton is part of
login procedure. Users are organized in groups(router in jabber) and shown with user icon picture and online status.
Chat system provides a chat window for each contact. The chat window can also minimized to icons lined on the right bottom corner
of the screen, right above the status bar.
Sample Code
NPL.load("(gl)script/kids/3DMapSystemUI/Chat/Main.lua");
Map3DSystem.App.Chat.OneTimeInit();
Member Functions
Map3DSystem.App.Chat.OneTimeInit
one time initialize to chat system
login to
JGSL chat during login procedure, see
Map3DSystem? .App.Login.Proc_Authentication
including:
-
- init the jabber client instant messanger
- init the os.window object for message process
syntax
function Map3DSystem.App.Chat.OneTimeInit()
Map3DSystem.App.Chat.MSGProc
Message Processor of Chat jabber client
it handles various messages
syntax
function Map3DSystem.App.Chat.MSGProc(window, msg)
parameters
Map3DSystem.App.Chat.IsInContactList
is JID in contact list
- param __ : JID of the user
syntax
function Map3DSystem.App.Chat.IsInContactList(JID)
parameters
Map3DSystem.App.Chat.UpdateContactList
update contact list
in online mode, contact information is retrieved from the jabber client
in offline mode, contact information is retrieved from the history
syntax
function Map3DSystem.App.Chat.UpdateContactList()
Map3DSystem.App.Chat.GetContactList
get the roster groups and roster items
- return __ : RosterGroups? and RosterItems?
syntax
function Map3DSystem.App.Chat.GetContactList()
parameters
| return |
RosterGroups? and RosterItems? |
Map3DSystem.App.Chat.SendMeMessage
send JCMain a message
syntax
function Map3DSystem.App.Chat.SendMeMessage(msg)
parameters
Map3DSystem.App.Chat.GetClient
Get default jabber client, create if not exist
It does not open a connection immediately.
syntax
function Map3DSystem.App.Chat.GetClient()
Map3DSystem.App.Chat.GetConnectedClient
get the currently connected client. return nil, if connection is not valid
syntax
function Map3DSystem.App.Chat.GetConnectedClient()
Map3DSystem.App.Chat.InitJabber
initiate the instant messager client
- param username : user name
- param password : password
- param servername : server name, "paraweb3d.com", "pala5.cn", "192.168.0.223" .etc
- param NetworkHost : the actuall IP address to connect to. If it is nil, IP address will be resolved from servername. Such as "192.168.0.223", "119.145.5.38" such as Map3DSystem? .App.Chat.InitIM("andy", "1234567", "pala5.cn")
syntax
function Map3DSystem.App.Chat.InitJabber(username, password, servername, NetworkHost)
parameters
| username |
user name |
| password |
|
| servername |
server name, "paraweb3d.com", "pala5.cn", "192.168.0.223" .etc |
| NetworkHost |
|
Map3DSystem.App.Chat.Jabber_OnPresence
received a presence packet
syntax
function Map3DSystem.App.Chat.Jabber_OnPresence()
Map3DSystem.App.Chat.Jabber_OnError
any kinds of error may goes here
syntax
function Map3DSystem.App.Chat.Jabber_OnError()
Map3DSystem.App.Chat.Jabber_OnRegistered
succesfully registered a user
After calling Register(), the registration succeeded or failed
syntax
function Map3DSystem.App.Chat.Jabber_OnRegistered()
Map3DSystem.App.Chat.Jabber_OnMessage
received a message packet
syntax
function Map3DSystem.App.Chat.Jabber_OnMessage()
Map3DSystem.App.Chat.Jabber_OnConnect
connection is established, user is still being authenticated.
The connection is connected, but no stream:stream has been sent, yet
syntax
function Map3DSystem.App.Chat.Jabber_OnConnect()
Map3DSystem.App.Chat.Jabber_OnDisconnect
gracefully disconnected.
The connection is disconnected
syntax
function Map3DSystem.App.Chat.Jabber_OnDisconnect()
Map3DSystem.App.Chat.Jabber_OnAuthError
use Jabber_OnError() instead. this function is not called.
Authentication failed. The connection is not terminated if there is an auth error and there is at least one event handler for this event.
syntax
function Map3DSystem.App.Chat.Jabber_OnAuthError()
Map3DSystem.App.Chat.Jabber_OnAuthenticate
user is authenticated
The connection is complete, and the user is authenticated
syntax
function Map3DSystem.App.Chat.Jabber_OnAuthenticate()
Map3DSystem.App.Chat.Jabber_OnSubscription
a new user added this user
syntax
function Map3DSystem.App.Chat.Jabber_OnSubscription()
Map3DSystem.App.Chat.Jabber_OnUnsubscription
a user unsubscribes from this user
syntax
function Map3DSystem.App.Chat.Jabber_OnUnsubscription()
Map3DSystem.App.Chat.Jabber_OnRosterBegin
we are beginning to retrieve contact list from the server. This usually happens automatically when user is authenticated.
Fired when a roster result starts, before any
OnRosterItem? events fire.
syntax
function Map3DSystem.App.Chat.Jabber_OnRosterBegin()
Map3DSystem.App.Chat.Jabber_OnRosterItem
[[
msg = {
Subscription = number, -- 0(to), 1(from), 2(both), 3(none), 4(remove)
JID = string, -- jabber ID
}
]]
event for new roster items. A roster may belong to multiple groups
syntax
function Map3DSystem.App.Chat.Jabber_OnRosterItem()
Map3DSystem.App.Chat.Jabber_OnRosterEnd
we have received all contact lists from the server. Usually we need to update the UI.
Fired when a roster result is completed being processed
syntax
function Map3DSystem.App.Chat.Jabber_OnRosterEnd()
Map3DSystem.App.Chat.GetNameFromJID
return the name of a Jabber ID, if not including any "@" sign the whole JID is returned
- param sJID : the given JID
- return __ : the name of the JID e.g. for JID:"andy@paraweb3d.com" it returns "andy"
syntax
function Map3DSystem.App.Chat.GetNameFromJID(sJID)
parameters
Map3DSystem.App.Chat.GetJIDFromJIDWithDomain
return JID of Full JID with domain, if not including any "/" sign the whole JID is returned
- param sJID : the given JID with domain name
- return __ : JID e.g. for JID:"andy2@pala5.cn/ParaWorld Chat" it returns "andy2@pala5.cn"
syntax
function Map3DSystem.App.Chat.GetJIDFromJIDWithDomain(sJIDFull)
parameters
Map3DSystem.App.Chat.InsertLatestReceiveMSGJID
insert the JID to the
LatestReceiveMSGJIDs? list
this function will automaticly sort the list according by receive time
index 1 will always get the latest receive message JID
syntax
function Map3DSystem.App.Chat.InsertLatestReceiveMSGJID(JID)
parameters
Map3DSystem.App.Chat.OnReceiveChatMessage
on receive chat message
syntax
function Map3DSystem.App.Chat.OnReceiveChatMessage(from, subject, body)
parameters
Map3DSystem.App.Chat.VisualizeMessage
show the message with
ChatWnd?
- param JID :
- param subject :
- param body :
syntax
function Map3DSystem.App.Chat.VisualizeMessage(JID, subject, body)
parameters
Map3DSystem.App.Chat.OnEnterWorld
called on entering world
syntax
function Map3DSystem.App.Chat.OnEnterWorld()
Map3DSystem.App.Chat.OnLeaveWorld
called on leaving world
syntax
function Map3DSystem.App.Chat.OnLeaveWorld()
Map3DSystem.App.Chat.GetSubscribed
Receive subscription, accept or decline
May the user with "JID" subscribe to the user?
syntax
function Map3DSystem.App.Chat.GetSubscribed(fromJID)
parameters
Map3DSystem.App.Chat.AddToFeed
WARNING: this is only TEST purpose feed on the original user interface
syntax
function Map3DSystem.App.Chat.AddToFeed(name, width, height)
parameters
Map3DSystem.App.Chat.RemoveFeed
WARNING: this is only TEST purpose feed on the original user interface
syntax
function Map3DSystem.App.Chat.RemoveFeed(name)
parameters
Instant messenging main window in Map 3D system
| Title |
Instant messenging main window in Map 3D system |
| Author(s) |
WangTian? |
| Date |
2007/10/12 |
| File |
script/kids/3DMapSystemUI/Chat/MainWnd.lua |
Description
Member Functions
Map3DSystem.UI.Chat.MainWnd.ShowMainWndUI
- param bShow : show or hide the panel
- param parentUI : parent container inside which the content is displayed. it can be nil.
- param parentWindow : parent window for sending messages
syntax
function Map3DSystem.UI.Chat.MainWnd.ShowMainWndUI(bShow, parentUI, parentWindow)
parameters
| bShow |
show or hide the panel |
| parentUI |
|
| parentWindow |
parent window for sending messages |
Map3DSystem.UI.Chat.MainWnd.OnUserIconClick
onclick function on the login user icon
syntax
function Map3DSystem.UI.Chat.MainWnd.OnUserIconClick()
Map3DSystem.UI.Chat.MainWnd.DrawContactNodeHandler
owner draw function of the contact list treeview
syntax
function Map3DSystem.UI.Chat.MainWnd.DrawContactNodeHandler(_parent, treeNode)
parameters
Map3DSystem.UI.Chat.MainWnd.UpdateContactList
update the entire UI
syntax
function Map3DSystem.UI.Chat.MainWnd.UpdateContactList()
Map3DSystem.UI.Chat.MainWnd.OnClickUser
called when clicking a user
- param treeNode : treenode of the contact treeview
syntax
function Map3DSystem.UI.Chat.MainWnd.OnClickUser(treeNode)
parameters
| treeNode |
treenode of the contact treeview |
Map3DSystem.UI.Chat.MainWnd.OnClickGroupContextMenuItem
group context menu event handler
- param menuItem :
- param UserNode :
syntax
function Map3DSystem.UI.Chat.MainWnd.OnClickGroupContextMenuItem(menuItem, UserNode)
parameters
Map3DSystem.UI.Chat.MainWnd.OnClickUserContextMenuItem
user context menu event handler
- param menuItem :
- param UserNode :
syntax
function Map3DSystem.UI.Chat.MainWnd.OnClickUserContextMenuItem(menuItem, UserNode)
parameters
Map3DSystem.UI.Chat.MainWnd.AddContact
add the contact shown in the textBoxAddContact text box
syntax
function Map3DSystem.UI.Chat.MainWnd.AddContact()
Map3DSystem.UI.Chat.MainWnd.ShowChatWithUser
show the
ChatWnd? instance for a given sJID, it will create the window if it has never been created before.
- param sJID : the JID of the communicate user
syntax
function Map3DSystem.UI.Chat.MainWnd.ShowChatWithUser(sJID)
parameters
| sJID |
the JID of the communicate user |
Map3DSystem.UI.Chat.MainWnd.ShowUserOnMap
TODO: show the user on the map
TODO: write proper command for map application
syntax
function Map3DSystem.UI.Chat.MainWnd.ShowUserOnMap(sJID)
parameters
Map3DSystem.UI.Chat.MainWnd.OnChangePersonalMsg
dirty