<commit_before>[[mobileoptimizations]]
Mobile Optimizations
====================
<NAME> <<EMAIL>>
v2.0, June 2014: Reformatted for AsciiDoc.
:toc:
:numbered:
:website: http://tigase.net/
:Date: 2012-05-22 17:57

Problem Description
-------------------

In default configuration stanzas are sent to client when processing is finished, but in mobile environment sending or receiving data drains battery due to use of radio. 

To save energy data should be sent to client only if it is important or client is waiting for it.

Solution
--------

When mobile client is entering inactive state it notifies server about it by sending following stanza:

[source,xml]
------------------------------------------------------------------
<iq type="set" id="xx">
<mobile 
  xmlns="http://tigase.org/protocol/mobile#v2" 
  enable="true"/>
</iq>
------------------------------------------------------------------

After receiving stanza server starts queueing presence stanza which should be send to mobile client. Any other stanza (such as iq or messenge) is sent immediately to the client.

When mobile client is entering active state it notifies server by sending following stanza:

[source,java]
------------------------------------------------------------------
<iq type="set" id="xx">
<mobile 
  xmlns="http://tigase.org/protocol/mobile#v2" 
  enable="false"/>
</iq>
------------------------------------------------------------------

After receiving stanza server sends all queued presence stanzas to the client.

Also all presence stanzas from queue will be sent if number of presence stanzas in queue will reach queue size limit. By default this limit is set to 50.

Queueing Algorithms
-------------------

There are two mobile optimization plugins for Tigase:

- *Mobile v1* - all presence stanzas are kept in queue
- *Mobile v2* - only last presence from each source is kept in queue


If you wish to activate you Mobile v1 plugin you need to send presented above with xmlns attribute value replaced with _http://tigase.org/protocol/mobile#v1_

Configuration
-------------

Mentioned plugins are not activated by default thus additional entries in the init.properties are required:

+--sm-plugins=+mobile_v1,+mobile_v2+
<commit_msg>Issue #2564 - added documentation for Mobile v3 optimization<commit_after>[[mobileoptimizations]]
Mobile Optimizations
====================
<NAME> <<EMAIL>>
v2.1, January 2015: Added info about MobileV3
v2.0, June 2014: Reformatted for AsciiDoc.
:toc:
:numbered:
:website: http://tigase.net/
:Date: 2012-05-22 17:57

Problem Description
-------------------

In default configuration stanzas are sent to client when processing is finished, but in mobile environment sending or receiving data drains battery due to use of radio. 

To save energy data should be sent to client only if it is important or client is waiting for it.

Solution
--------

When mobile client is entering inactive state it notifies server about it by sending following stanza:

[source,xml]
------------------------------------------------------------------
<iq type="set" id="xx">
<mobile 
  xmlns="http://tigase.org/protocol/mobile#v3" 
  enable="true"/>
</iq>
------------------------------------------------------------------

After receiving stanza server starts queueing stanza which should be send to mobile client. Kind of queued stanzas depends on used plugin and in case of *Mobile v3* presence stanzas are queued as well as message stanzas which are Message Carbons. Any other stanza (such as iq or plain messenge) is sent immediately to the client and every stanza from queue is also sent at this time.

When mobile client is entering active state it notifies server by sending following stanza:

[source,xml]
------------------------------------------------------------------
<iq type="set" id="xx">
<mobile 
  xmlns="http://tigase.org/protocol/mobile#v3" 
  enable="false"/>
</iq>
------------------------------------------------------------------

After receiving stanza server sends all queued stanzas to the client.

Also all stanzas from queue will be sent if number of stanzas in queue will reach queue size limit. By default this limit is set to 50.

Queueing Algorithms
-------------------

There are three mobile optimization plugins for Tigase:

- *Mobile v1* - all presence stanzas are kept in queue
- *Mobile v2* - only last presence from each source is kept in queue
- *Mobile v3* - only last presence from each source is kept in queue, also Message Carbons are queued


If you wish to activate you Mobile v1 plugin you need to send presented above with xmlns attribute value replaced with _http://tigase.org/protocol/mobile#v1_

If you wish to activate you Mobile v2 plugin you need to send presented above with xmlns attribute value replaced with _http://tigase.org/protocol/mobile#v2_

Configuration
-------------

Mentioned plugins are not activated by default thus additional entries in the init.properties are required:

+--sm-plugins=+mobile_v1,+mobile_v2,+mobile_v3

*Only one of this plugins should be enabled*

{'fraction_non_alphanumeric': 0.19274960380348652, 'fraction_numerical': 0.014461172741679873, 'mean_word_length': 2.50625, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4049982', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1214, 'n_words': 604}