Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
gajim
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
203
Issues
203
List
Boards
Labels
Service Desk
Milestones
Merge Requests
21
Merge Requests
21
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gajim
gajim
Commits
9c8b63af
Commit
9c8b63af
authored
May 31, 2011
by
zimio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Checks for stanzas handled by server
parent
5b1edd03
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
3 deletions
+30
-3
src/common/xmpp/dispatcher_nb.py
src/common/xmpp/dispatcher_nb.py
+7
-0
src/common/xmpp/smacks.py
src/common/xmpp/smacks.py
+23
-3
No files found.
src/common/xmpp/dispatcher_nb.py
View file @
9c8b63af
...
...
@@ -533,6 +533,13 @@ def send(self, stanza, now=False):
ID
=
stanza
.
getID
()
if
self
.
_owner
.
_registered_name
and
not
stanza
.
getAttr
(
'from'
):
stanza
.
setAttr
(
'from'
,
self
.
_owner
.
_registered_name
)
if
self
.
supports_sm
:
self
.
sm
.
uqueue
.
append
(
stanza
)
self
.
sm
.
out_h
=
self
.
sm
.
out_h
+
1
if
len
(
self
.
sm
.
uqueue
)
>
self
.
sm
.
max_queue
:
self
.
sm
.
request_ack
()
self
.
_owner
.
Connection
.
send
(
stanza
,
now
)
return
ID
...
...
src/common/xmpp/smacks.py
View file @
9c8b63af
from
protocol
import
Acks
from
protocol
import
NS_STREAM_MGMT
import
logging
log
=
logging
.
getLogger
(
'gajim.c.x.smacks'
)
class
Smacks
():
'''
...
...
@@ -16,13 +18,16 @@ def __init__(self, owner):
self
.
out_h
=
0
# Outgoing stanzas handled
self
.
in_h
=
0
# Incoming stanzas handled
self
.
uqueue
=
[]
# Unhandled stanzas queue
#Register handlers
# Max number of stanzas in queue before making a request
self
.
max_queue
=
5
# Register handlers
owner
.
Dispatcher
.
RegisterNamespace
(
NS_STREAM_MGMT
)
owner
.
Dispatcher
.
RegisterHandler
(
'enabled'
,
self
.
_neg_response
,
xmlns
=
NS_STREAM_MGMT
)
owner
.
Dispatcher
.
RegisterHandler
(
'r'
,
self
.
send_ack
,
xmlns
=
NS_STREAM_MGMT
)
owner
.
Dispatcher
.
RegisterHandler
(
'a'
,
self
.
check_ack
,
xmlns
=
NS_STREAM_MGMT
)
def
negociate
(
self
):
...
...
@@ -42,3 +47,18 @@ def request_ack(self):
r
=
Acks
()
r
.
buildRequest
()
self
.
_owner
.
Connection
.
send
(
r
,
False
)
def
check_ack
(
self
,
disp
,
stanza
):
h
=
int
(
stanza
.
getAttr
(
'h'
))
diff
=
self
.
out_h
-
h
if
len
(
self
.
uqueue
)
<
diff
or
diff
<
0
:
log
.
error
(
'Server and client number of stanzas handled mismatch '
)
return
while
(
len
(
self
.
uqueue
)
>
diff
):
self
.
uqueue
.
pop
(
0
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment