Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: fb32bca69a
Fetching contributors…

Cannot retrieve contributors at this time

183 lines (172 sloc) 5.087 kb
%{
//-----------------------------------------------------------------------------
//
// Project: STOMP for OpenZWave
//
// a simple STOMP (Simple Text Oriented Messaging Protocol) client
// for more info on the protocol, see URL: http://stomp.github.com/
//
// 1) subscribes to STOMP queues to pass ZWave commands to OpenZWave
// 2) sends to STOMP queues ZWave notifications by OpenZWave's Notification mechanism
//
// Copyright (c) 2011 Elias Karakoulakis
//
// SOFTWARE NOTICE AND LICENSE
//
// This file is part of Thrift4OZW.
//
// Thrift4OZW is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// Thrift4OZW is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Thrift4OZW. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
%}
%class PocoStomp
%header PocoStomp.h
%include PocoStomp.h
%package STOMP
%start StompFSM_map::Disconnected
%map StompFSM_map
%%
// ############
Disconnected
{
socket_connected
SocketConnected {
debug_print("socket connected!\n");
}
// --------
socket_disconnected Disconnected {
debug_print("STOMP server disconnected! retrying connection...");
}
}
// ############
SocketConnected
{
send_frame(_frame: PFrame) [
(_frame->command.compare("CONNECT") == 0)
] Ready {
initialized(); // signal I/O thread to start
debug_print("CONNECT");
}
// --------
socket_disconnected Disconnected {
debug_print("STOMP server disconnected! retrying connection...");
}
}
// ############
Ready
{
// -------- Sending frames (client->server)---------
// DISCONNECT
send_frame(_frame: PFrame) [
(_frame->command.compare("DISCONNECT") == 0)
] Disconnecting {
start_timer(&StompFSM_map::Disconnecting);
debug_print("Disconnecting...\n");
}
// SUBSCRIBE
send_frame(_frame: PFrame) [
(_frame->command.compare("SUBSCRIBE") == 0)
] Ready {
debug_print("SUBSCRIBE");
}
// other command frames (client->server),
send_frame(_frame: PFrame)
Ready {
debug_print("StompClient: send_frame\n");
}
// -------- Receiving frames (server->client)---------
// CONNECTED
receive_frame(_frame: PFrame) [
(_frame->command.compare("CONNECTED") == 0)
] Ready {
debug_print("CONNECTED!\n");
}
// MESSAGE frame, ack: AUTO
receive_frame(_frame: PFrame) [
(_frame->command.compare("MESSAGE") == 0)
&&
(ctxt.get_ackmode() == ACK_AUTO)
] Ready {
debug_print("MESSAGE frame from STOMP server!\n");
notify_callbacks(_frame);
}
// MESSAGE frame, ack: CLIENT
receive_frame(_frame: PFrame) [
(_frame->command.compare("MESSAGE") == 0)
&&
(ctxt.get_ackmode() == ACK_CLIENT)
] SendingAck {
debug_print("MESSAGE frame from STOMP server!\n");
notify_callbacks(_frame);
}
// RECEIPT frame, ack: AUTO
receive_frame(_frame: PFrame) [
(_frame->command.compare("RECEIPT") == 0)
&&
(ctxt.get_ackmode() == ACK_AUTO)
] Ready {
debug_print("RECEIPT, ack:AUTO\n");
}
// RECEIPT frame, ack: CLIENT
receive_frame(_frame: PFrame) [
(_frame->command.compare("RECEIPT") == 0)
&&
(ctxt.get_ackmode() == ACK_CLIENT)
] SendingAck {
debug_print("RECEIPT, ack:CLIENT\n");
}
// ERROR frame
receive_frame(_frame: PFrame) [
(_frame->command.compare("ERROR") == 0)
] Ready {
debug_print("ERROR frame from STOMP server!\n");
}
// ------------------------
timeout Ready {
debug_print("timeout waiting for full STOMP frame!");
}
// ------------------------
socket_disconnected Disconnected {
socket_shutdown();
debug_print("STOMP server disconnected! retrying connection...");
}
}
// ############
SendingAck
{
send_frame(_frame: PFrame) [
(_frame->command.compare("ACK") == 0)
&&
(ctxt.get_ackmode() == ACK_CLIENT)
] Ready {
}
}
// ############
Disconnecting
{
timeout(waitingfor: PocoStompState*)[
strcmp(waitingfor->getName(), "Disconnecting")==0
]
Disconnected {
debug_print("ooops, timed out disconnecting!!");
}
ack_received(_frame: PFrame) [
_frame->command.compare("DISCONNECT")==0
]
Disconnected {
stop_timer();
debug_print("ACK received!");
}
}
%%
Jump to Line
Something went wrong with that request. Please try again.