Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F299104
StompProcessor.pike
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Dec 25, 9:40 PM
Size
1 KB
Mime Type
text/plain
Expires
Fri, Dec 27, 9:40 PM (3 w, 5 d ago)
Engine
blob
Format
Raw Data
Handle
60535
Attached To
R148 fins
StompProcessor.pike
View Options
import
Fins
;
import
Tools
.
Logging
;
inherit
Processor
;
object
stomp
;
mapping
listeners
=
([]);
mapping
r_listeners
=
([]);
array
supported_protocols
()
{
return
({
"Stomp"
});
}
void
start
()
{
if
(
!
config
[
"stomp"
])
throw
(
Error
.
Generic
(
"No Stomp configuration section.
\n
"
));
else
{
#if constant(Public.Protocols.Stomp)
stomp
=
Public
.
Protocols
.
Stomp
.
Client
(
config
[
"stomp"
][
"broker"
],
1
);
#else
throw
(
Error
.
Generic
(
"Public.Protocols.Stomp module not available.
\n
"
));
#endif
}
}
void
register_subscriber
(
object
to
)
{
// if(listeners[to]) unregister_subscriber(to);
listeners
[
to
]
=
to
->
subscribes_to
;
r_listeners
[
to
->
subscribes_to
]
=
to
;
stomp
->
subscribe
(
to
->
subscribes_to
,
lambda
(
object
frame
){
return
process_message
(
frame
,
to
->
subscribes_to
);
});
}
int
process_message
(
object
frame
,
string
to
)
{
object
e
;
object
c
;
int
r
;
// write("got a frame: %O\n", frame);
if
((
int
)(
config
[
"controller"
][
"reload"
]))
{
app
->
controller_updated
(
r_listeners
[
to
],
app
,
"controller"
);
}
c
=
r_listeners
[
to
];
e
=
catch
{
if
(
c
&&
c
->
on_message
&&
functionp
(
c
->
on_message
))
c
->
on_message
(
StompRequest
(
frame
));
};
if
(
e
)
{
Log
.
exception
(
"an error occurred while calling on_message()
\n
"
,
e
);
return
0
;
}
else
return
1
;
}
mixed
handle
(
Request
request
)
{
}
void
publish
(
string
destination
,
string
body
,
mapping
|
void
headers
)
{
stomp
->
send
(
destination
,
body
,
headers
);
}
Event Timeline
Log In to Comment