Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
191f569b
Commit
191f569b
authored
Mar 19, 2013
by
Michal 'vorner' Vaner
Browse files
[2737] Use the constants is isc.cc.session
parent
f687f770
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/python/isc/cc/session.py
View file @
191f569b
...
...
@@ -57,11 +57,11 @@ class Session:
try
:
self
.
_socket
=
socket
.
socket
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
)
self
.
_socket
.
connect
(
self
.
socket_file
)
self
.
sendmsg
({
"type"
:
"getlname"
})
self
.
sendmsg
({
CC_HEADER_TYPE
:
CC_COMMAND_GET_LNAME
})
env
,
msg
=
self
.
recvmsg
(
False
)
if
not
env
:
raise
ProtocolError
(
"Could not get local name"
)
self
.
_lname
=
msg
[
"lname"
]
self
.
_lname
=
msg
[
CC_HEADER_LNAME
]
if
not
self
.
_lname
:
raise
ProtocolError
(
"Could not get local name"
)
logger
.
debug
(
logger
.
DBGLVL_TRACE_BASIC
,
PYCC_LNAME_RECEIVED
,
...
...
@@ -125,9 +125,10 @@ class Session:
if
len
(
self
.
_queue
)
>
0
:
i
=
0
;
for
env
,
msg
in
self
.
_queue
:
if
seq
!=
None
and
"reply"
in
env
and
seq
==
env
[
"reply"
]:
if
seq
!=
None
and
CC_HEADER_REPLY
in
env
and
\
seq
==
env
[
CC_HEADER_REPLY
]:
return
self
.
_queue
.
pop
(
i
)
elif
seq
==
None
and
"reply"
not
in
env
:
elif
seq
==
None
and
CC_HEADER_REPLY
not
in
env
:
return
self
.
_queue
.
pop
(
i
)
else
:
i
=
i
+
1
...
...
@@ -141,7 +142,9 @@ class Session:
if
data_length
>
0
:
env
=
isc
.
cc
.
message
.
from_wire
(
data
[
2
:
header_length
+
2
])
msg
=
isc
.
cc
.
message
.
from_wire
(
data
[
header_length
+
2
:])
if
(
seq
==
None
and
"reply"
not
in
env
)
or
(
seq
!=
None
and
"reply"
in
env
and
seq
==
env
[
"reply"
]):
if
(
seq
==
None
and
CC_HEADER_REPLY
not
in
env
)
or
\
(
seq
!=
None
and
CC_HEADER_REPLY
in
env
and
seq
==
env
[
CC_HEADER_REPLY
]):
return
env
,
msg
else
:
self
.
_queue
.
append
((
env
,
msg
))
...
...
@@ -248,18 +251,18 @@ class Session:
self
.
_sequence
+=
1
return
self
.
_sequence
def
group_subscribe
(
self
,
group
,
instance
=
"*"
):
def
group_subscribe
(
self
,
group
,
instance
=
CC_INSTANCE_WILDCARD
):
self
.
sendmsg
({
"type"
:
"subscribe"
,
"group"
:
group
,
"instance"
:
instance
,
CC_HEADER_TYPE
:
CC_COMMAND_SUBSCRIBE
,
CC_HEADER_GROUP
:
group
,
CC_HEADER_INSTANCE
:
instance
,
})
def
group_unsubscribe
(
self
,
group
,
instance
=
"*"
):
def
group_unsubscribe
(
self
,
group
,
instance
=
CC_INSTANCE_WILDCARD
):
self
.
sendmsg
({
"type"
:
"unsubscribe"
,
"group"
:
group
,
"instance"
:
instance
,
CC_HEADER_TYPE
:
CC_COMMAND_UNSUBSCRIBE
,
CC_HEADER_GROUP
:
group
,
CC_HEADER_INSTANCE
:
instance
,
})
def
group_sendmsg
(
self
,
msg
,
group
,
instance
=
CC_INSTANCE_WILDCARD
,
...
...
@@ -308,13 +311,13 @@ class Session:
def
group_reply
(
self
,
routing
,
msg
):
seq
=
self
.
_next_sequence
()
self
.
sendmsg
({
"type"
:
"send"
,
"from"
:
self
.
_lname
,
"to"
:
routing
[
"from"
],
"group"
:
routing
[
"group"
],
"instance"
:
routing
[
"instance"
],
"seq"
:
seq
,
"reply"
:
routing
[
"seq"
],
CC_HEADER_TYPE
:
CC_COMMAND_SEND
,
CC_HEADER_FROM
:
self
.
_lname
,
CC_HEADER_TO
:
routing
[
CC_HEADER_FROM
],
CC_HEADER_GROUP
:
routing
[
CC_HEADER_GROUP
],
CC_HEADER_INSTANCE
:
routing
[
CC_HEADER_INSTANCE
],
CC_HEADER_SEQ
:
seq
,
CC_HEADER_REPLY
:
routing
[
CC_HEADER_SEQ
],
},
isc
.
cc
.
message
.
to_wire
(
msg
))
return
seq
...
...
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