XEP-0047: In-band Bytestreams¶
- class slixmpp.plugins.xep_0047.XEP_0047(xmpp, config=None)[source]¶
XEP-0047: In-Band Bytestreams
Events registered by this plugin:
Plugin Parameters:
block_size
(default:4096
): default block size to negociatemax_block_size
(default:8192
): max block size to acceptauto_accept
(default:False
): if incoming streams should beaccepted automatically.
- default_config: ClassVar[Dict[str, Any]] = {'auto_accept': False, 'block_size': 4096, 'max_block_size': 8192}¶
The basic, standard configuration for the plugin, which may be overridden when initializing the plugin. The configuration fields included here may be accessed directly as attributes of the plugin. For example, including the configuration field ‘foo’ would mean accessing plugin.foo returns the current value of plugin.config[‘foo’].
- dependencies: ClassVar[Set[str]] = {'xep_0030'}¶
Some plugins may depend on others in order to function properly. Any plugin names included in
dependencies
will be initialized as needed if this plugin is enabled.
- description: str = 'XEP-0047: In-Band Bytestreams'¶
A longer name for the plugin, describing its purpose. For example, a plugin for XEP-0030 would use ‘Service Discovery’ as its description value.
- name: str = 'xep_0047'¶
A short name for the plugin based on the implemented specification. For example, a plugin for XEP-0030 would use ‘xep_0030’.
- async open_stream(jid, *, block_size=None, sid=None, use_messages=False, ifrom=None, **iqkwargs)[source]¶
Open an IBB stream with a peer JID.
Changed in version 1.8.0: This function is now a coroutine and must be awaited. All parameters except
jid
are keyword-args only.- Parameters:
jid (
JID
) – The remote JID to initiate the stream with.block_size (
Optional
[int
]) – The block size to advertise.sid (
Optional
[str
]) – The IBB stream id (if not provided, will be auto-generated).use_messages (
bool
) – If the stream should use message stanzas instead of iqs.
- Return type:
- Returns:
The opened byte stream with the remote JID
- Raises:
.IqError – When the remote entity denied the stream.
- class slixmpp.plugins.xep_0047.IBBytestream(xmpp, sid, block_size, jid, peer, use_messages=False)[source]¶
XEP-0047 Stream abstraction. Created by the ibb plugin automatically.
Provides send methods and triggers ibb_stream_data events.
- async gather(max_data=None, timeout=3600)[source]¶
Gather all data sent on a stream until it is closed, and return it.
Added in version 1.8.0.
- Parameters:
max_data (
Optional
[int
]) – Max number of bytes to receive. (received data may be over this limit depending on block_size)timeout (
int
) – Timeout after which an error will be raised.
- Raises:
.IqTimeout – If the timeout is reached.
- Return type:
bytes
- Returns:
All bytes accumulated in the stream.
- async send(data, timeout=None)[source]¶
Send a single block of data.
- Parameters:
data (
bytes
) – Data to send (will be truncated if above block size).- Return type:
int
- Returns:
Number of bytes sent.
Internal API methods¶
The API here is used to manage streams and authorize. The default handlers work with the config parameters.
jid:
JID
receiving the stream initiation.node: stream id
ifrom: who the stream is from.
args:
Iq
of the stream request.returns:
True
if the stream should be accepted,False
otherwise.
Check if the stream should be accepted. Uses the information setup by preauthorize_sid (0047 version) by default.
jid:
JID
receiving the stream initiation.node: stream id
ifrom: who the stream is from.
args:
Iq
of the stream request.returns:
True
if the stream should be accepted,False
otherwise.
A fallback handler (run after authorized_sid (0047 version)) to check if a stream should be accepted. Uses the
auto_accept
parameter by default.jid:
JID
receiving the stream initiation.node: stream id
ifrom: who the stream will be from.
args: Unused.
Register a stream id to be accepted automatically (called from other plugins such as XEP-0095).
- get_stream¶
jid:
JID
of local receiver.node: stream id
ifrom: who the stream is from.
args: unused
returns:
IBBytestream
Return a currently opened stream between two JIDs.
- set_stream¶
jid:
JID
of local receiver.node: stream id
ifrom: who the stream is from.
args: unused
Register an opened stream between two JIDs.
- del_stream¶
jid:
JID
of local receiver.node: stream id
ifrom: who the stream is from.
args: unused
Delete a stream between two JIDs.
Stanza elements¶
- class slixmpp.plugins.xep_0047.stanza.Close(xml=None, parent=None)[source]¶
- interfaces: ClassVar[Set[str]] = {'sid'}¶
The set of keys that the stanza provides for accessing and manipulating the underlying XML object. This set may be augmented with the
plugin_attrib
value of any registered stanza plugins.
- name: ClassVar[str] = 'close'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBase
object for<message />
would usename = 'message'
.
- namespace: str = 'http://jabber.org/protocol/ibb'¶
The XML namespace for the element. Given
<foo xmlns="bar" />
, thennamespace = "bar"
should be used. The default namespace isjabber:client
since this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'ibb_close'¶
For
ElementBase
subclasses which are intended to be used as plugins, theplugin_attrib
value defines the plugin name. Plugins may be accessed by using theplugin_attrib
value as the interface. An example usingplugin_attrib = 'foo'
:register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- class slixmpp.plugins.xep_0047.stanza.Data(xml=None, parent=None)[source]¶
-
- interfaces: ClassVar[Set[str]] = {'data', 'seq', 'sid'}¶
The set of keys that the stanza provides for accessing and manipulating the underlying XML object. This set may be augmented with the
plugin_attrib
value of any registered stanza plugins.
- name: ClassVar[str] = 'data'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBase
object for<message />
would usename = 'message'
.
- namespace: str = 'http://jabber.org/protocol/ibb'¶
The XML namespace for the element. Given
<foo xmlns="bar" />
, thennamespace = "bar"
should be used. The default namespace isjabber:client
since this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'ibb_data'¶
For
ElementBase
subclasses which are intended to be used as plugins, theplugin_attrib
value defines the plugin name. Plugins may be accessed by using theplugin_attrib
value as the interface. An example usingplugin_attrib = 'foo'
:register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- sub_interfaces: ClassVar[Set[str]] = {'data'}¶
A subset of
interfaces
which maps interfaces to direct subelements of the underlying XML object. Using this set, the text of these subelements may be set, retrieved, or removed without needing to define custom methods.
- class slixmpp.plugins.xep_0047.stanza.Open(xml=None, parent=None)[source]¶
-
- interfaces: ClassVar[Set[str]] = {'block_size', 'sid', 'stanza'}¶
The set of keys that the stanza provides for accessing and manipulating the underlying XML object. This set may be augmented with the
plugin_attrib
value of any registered stanza plugins.
- name: ClassVar[str] = 'open'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBase
object for<message />
would usename = 'message'
.
- namespace: str = 'http://jabber.org/protocol/ibb'¶
The XML namespace for the element. Given
<foo xmlns="bar" />
, thennamespace = "bar"
should be used. The default namespace isjabber:client
since this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'ibb_open'¶
For
ElementBase
subclasses which are intended to be used as plugins, theplugin_attrib
value defines the plugin name. Plugins may be accessed by using theplugin_attrib
value as the interface. An example usingplugin_attrib = 'foo'
:register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']