chat history
-
- Posts: 6
- Joined: 24 Dec 2017, 15:51
chat history
How to make avatar chat, I can view the message history, which will shows the last five messages? How to view a log of messages sent from users in control panel?
Re: chat history
Hi,
user's messages are not stored by default, but you can create a storage system via server side code.
In your Extension code you can listen for any public/private message being sent by adding an event handler for SFSEvent.PUBLIC_MESSAGE and SFSEvent.PRIVATE_MESSAGE.
From there you can simply accumulate those messages in a list/queue and then flush them to the database when the user leaves / disconnects.
Hope it helps
user's messages are not stored by default, but you can create a storage system via server side code.
In your Extension code you can listen for any public/private message being sent by adding an event handler for SFSEvent.PUBLIC_MESSAGE and SFSEvent.PRIVATE_MESSAGE.
From there you can simply accumulate those messages in a list/queue and then flush them to the database when the user leaves / disconnects.
Hope it helps
Re: chat history
Lapo wrote:Hi,
user's messages are not stored by default, but you can create a storage system via server side code.
In your Extension code you can listen for any public/private message being sent by adding an event handler for SFSEvent.PUBLIC_MESSAGE and SFSEvent.PRIVATE_MESSAGE.
From there you can simply accumulate those messages in a list/queue and then flush them to the database when the user leaves / disconnects.
Hope it helps
Hi
I've register
this.addEventListener(SFSEventType.PRIVATE_MESSAGE, ReceivePrivateMessage.class);
But ReceivePrivateMessage.class base on class ????
public class ReceivePrivateMessage extends BaseSFSEventListener ??? correct
Re: chat history
Hi,
the method to listen for a server-side event is addEventHandler()
For example:
The event sends a number of objects which are documented in the javadoc:
http://docs2x.smartfoxserver.com/api-do ... TE_MESSAGE
Which you can extract like this:
More on this here:
http://docs2x.smartfoxserver.com/Extens ... a/overview
Cheers
the method to listen for a server-side event is addEventHandler()
For example:
Code: Select all
addEventHandler(SFSEventType.PRIVATE_MESSAGE, PrivMessageHandler.class);
The event sends a number of objects which are documented in the javadoc:
http://docs2x.smartfoxserver.com/api-do ... TE_MESSAGE
Which you can extract like this:
Code: Select all
@Override
public void handleServerEvent(ISFSEvent event) throws SFSException
{
User user = (User) event.getParameter(SFSEventParam.USER);
// etc...
}
http://docs2x.smartfoxserver.com/Extens ... a/overview
Cheers
Re: chat history
Thanks so much
Who is online
Users browsing this forum: Baidu [Spider] and 63 guests