How two events can be send from Crank Storyboard to external application in C. When I send only one event it works fine. But when I send two events, the data get mixed. Should I create two channels for receiving the data or one is enough, or what exactly should be different when the event is received?
The code in Lua:
1) First Event
function updateposition(mapargs)
local format = "4s1 int32 2s1 int16"
local data = {}
local positionx
local positiony
data["int32"] = positionx["x"]
data["int16"] = positiony["y"]
gre.send_event_data("Myevent", format, data, "goal_receive")
end
2) Second Event
function sendgoaldata()
local format = "1s1 int8 2s1 int16 2u1 uint16 1u1 uint8 1s1 int8 "
local data = {}
local xG1,xG2,xG3,xG4
data["int8"] = xG1["x"]
data["int16"] = yG1["y"]
data["uint16"] = wG1["width"]
data["uint8"] = hG1["height"]
gre.send_event_data("goalInfo", format, data, "goal_receive")
end
The code in C:
rhandle = gre_io_open("goal_receive", GRE_IO_TYPE_RDONLY);
ret = gre_io_receive(rhandle, &nbuffer);
rnbytes = gre_io_unserialize(nbuffer, &revent_target, &revent_name, &revent_format, (void **) &revent_data); //First Event
my_data = (struct receive_data *) revent_data;
rnbytes = gre_io_unserialize(nbuffer, &revent_target, &revent_name,&revent_format, (void **) &revent_data); //Second Event
myGoal=(struct goalData *) revent_data;
Thank you

All the best,
Atinir