![]() |
![]() |
![]() |
libinfinity-0.5 Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties | Signals |
#include <libinfinity/common/inf-chat-session.h> InfChatSession; struct InfChatSessionClass; enum InfChatSessionError; InfChatSession * inf_chat_session_new (InfCommunicationManager *manager
,guint backlog_size
,InfSessionStatus status
,InfCommunicationGroup *sync_group
,InfXmlConnection *sync_connection
); gboolean inf_chat_session_set_log_file (InfChatSession *session
,const gchar *log_file
,GError **error
);
InfChatSession represents a chat session. Normally, there is one chat
session per server, and it can be enabled via infd_directory_enable_chat()
.
Clients can subscribe to the chat session via
infc_browser_subscribe_chat()
.
typedef struct _InfChatSession InfChatSession;
InfChatSession is an opaque data type. You should only access it via the public API functions.
struct InfChatSessionClass { void (*receive_message)(InfChatSession* session, const InfChatBufferMessage* message); void (*send_message)(InfChatSession* session, const InfChatBufferMessage* message); };
This structure contains default signal handlers for InfChatSession.
Default signal handler for the "receive-message" signal. | |
Default signal handler for the "send-message" signal. |
typedef enum { INF_CHAT_SESSION_ERROR_TYPE_INVALID, INF_CHAT_SESSION_ERROR_NO_SUCH_USER, INF_CHAT_SESSION_ERROR_FAILED } InfChatSessionError;
Errors that can occur with a chat session, especially in the process_xml_sync and process_xml_run vfunc implementations.
InfChatSession * inf_chat_session_new (InfCommunicationManager *manager
,guint backlog_size
,InfSessionStatus status
,InfCommunicationGroup *sync_group
,InfXmlConnection *sync_connection
);
Creates a new InfChatSession with no initial messages. The communication manager is used to send and receive requests from subscription and synchronization.
backlog_size
specifies how much messages to save before dropping old
messages. This also limits how many old messages are transferred when
synchronizing the session.
If status
is INF_SESSION_PRESYNC
or INF_SESSION_SYNCHRONIZING
, then the
session will initially be synchronized, meaning an initial backlog is
retrieved from sync_connection
(which must not be NULL
in this case). If
you are subscribed to the session, set the subscription group via
inf_session_set_subscription_group()
.
|
A InfCommunicationManager. |
|
The number of messages to store. |
|
Initial status of the session. If this is
INF_SESSION_SYNCHRONIZING or INF_SESSION_PRESYNC , then sync_group and
sync_connection need to be set. |
|
A group in which the session is synchronized. Ignored if
status is INF_SESSION_RUNNING . |
|
A connection to synchronize the session from. Ignored if
status is INF_SESSION_RUNNING . |
Returns : |
A new InfChatSession. |
gboolean inf_chat_session_set_log_file (InfChatSession *session
,const gchar *log_file
,GError **error
);
Sets a file onto which all received messages are appended. The file is created if it does not exist. If a previous log file was set, then it is closed before opening the new file.
Backlog messages received upon synchronization are not logged.
|
A InfChatSession. |
|
A filename to store all received messages into. |
|
Location to store error information, if any. |
Returns : |
TRUE if the log file could be opened, FALSE otherwise (in which
case error is set). |
"receive-message"
signalvoid user_function (InfChatSession *session,
InfChatBufferMessage *message,
gpointer user_data) : Run Last
This signal is emitted whenever a message has been received. If the
session is in INF_SESSION_SYNCHRONIZING
state the received message was
a backlog message.
|
The InfChatSession that is receiving a message. |
|
The InfChatBufferMessage that was received. |
|
user data set when the signal handler was connected. |
"send-message"
signalvoid user_function (InfChatSession *session,
InfChatBufferMessage *message,
gpointer user_data) : Run Last
This signal is emitted whenever a message is sent. Messages can be sent
by calling inf_chat_buffer_add_message()
or
inf_chat_buffer_add_emote_message()
on the session's InfChatBuffer.
Messages of type INF_CHAT_BUFFER_MESSAGE_USERJOIN
or
INF_CHAT_BUFFER_MESSAGE_USERPART
can not be sent explicitely, so this
signal will never be emitted for such messages.
|
The InfChatSession that is sending a message. |
|
The InfChatBufferMessage that is sent. |
|
user data set when the signal handler was connected. |