custom packets callbacks fix
This commit is contained in:
parent
5367764fdc
commit
ecf045182a
2 changed files with 9 additions and 6 deletions
|
@ -274,16 +274,18 @@ def lossless_packet(tox, friend_number, data, length, user_data):
|
||||||
"""
|
"""
|
||||||
Incoming lossless packet
|
Incoming lossless packet
|
||||||
"""
|
"""
|
||||||
|
data = data[:length]
|
||||||
plugin = PluginLoader.get_instance()
|
plugin = PluginLoader.get_instance()
|
||||||
invoke_in_main_thread(plugin.callback_lossless, friend_number, data, length)
|
invoke_in_main_thread(plugin.callback_lossless, friend_number, data)
|
||||||
|
|
||||||
|
|
||||||
def lossy_packet(tox, friend_number, data, length, user_data):
|
def lossy_packet(tox, friend_number, data, length, user_data):
|
||||||
"""
|
"""
|
||||||
Incoming lossy packet
|
Incoming lossy packet
|
||||||
"""
|
"""
|
||||||
|
data = data[:length]
|
||||||
plugin = PluginLoader.get_instance()
|
plugin = PluginLoader.get_instance()
|
||||||
invoke_in_main_thread(plugin.callback_lossy, friend_number, data, length)
|
invoke_in_main_thread(plugin.callback_lossy, friend_number, data)
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -64,23 +64,24 @@ class PluginLoader(util.Singleton):
|
||||||
self._plugins[inst.get_short_name()] = [inst, autostart] # (inst, is active)
|
self._plugins[inst.get_short_name()] = [inst, autostart] # (inst, is active)
|
||||||
break
|
break
|
||||||
|
|
||||||
def callback_lossless(self, friend_number, data, length):
|
def callback_lossless(self, friend_number, data):
|
||||||
"""
|
"""
|
||||||
New incoming custom lossless packet (callback)
|
New incoming custom lossless packet (callback)
|
||||||
"""
|
"""
|
||||||
|
print('Custom', data)
|
||||||
l = data[0] - pl.LOSSLESS_FIRST_BYTE
|
l = data[0] - pl.LOSSLESS_FIRST_BYTE
|
||||||
name = ''.join(chr(x) for x in data[1:l + 1])
|
name = ''.join(chr(x) for x in data[1:l + 1])
|
||||||
if name in self._plugins and self._plugins[name][1]:
|
if name in self._plugins and self._plugins[name][1]:
|
||||||
self._plugins[name][0].lossless_packet(''.join(chr(x) for x in data[l + 1:length]), friend_number)
|
self._plugins[name][0].lossless_packet(''.join(chr(x) for x in data[l + 1:]), friend_number)
|
||||||
|
|
||||||
def callback_lossy(self, friend_number, data, length):
|
def callback_lossy(self, friend_number, data):
|
||||||
"""
|
"""
|
||||||
New incoming custom lossy packet (callback)
|
New incoming custom lossy packet (callback)
|
||||||
"""
|
"""
|
||||||
l = data[0] - pl.LOSSY_FIRST_BYTE
|
l = data[0] - pl.LOSSY_FIRST_BYTE
|
||||||
name = ''.join(chr(x) for x in data[1:l + 1])
|
name = ''.join(chr(x) for x in data[1:l + 1])
|
||||||
if name in self._plugins and self._plugins[name][1]:
|
if name in self._plugins and self._plugins[name][1]:
|
||||||
self._plugins[name][0].lossy_packet(''.join(chr(x) for x in data[l + 1:length]), friend_number)
|
self._plugins[name][0].lossy_packet(''.join(chr(x) for x in data[l + 1:]), friend_number)
|
||||||
|
|
||||||
def friend_online(self, friend_number):
|
def friend_online(self, friend_number):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue