wwy
February 21, 2016, 9:17pm
1
Hi,
My firmware creates 2 events named resultEvent and statusEvent. I can see them in Dashboard.
However in the onEvent function, the eventName string is always “message”. Has anyone seen this?
Thanks.
eventHandler = new ParticleEventHandler() {
@Override
public void onEvent(String eventName, ParticleEvent particleEvent) {
if (eventName == "statusEvent") {
updateTextViews(particleEvent.dataPayload);
}
else if (eventName == "resultEvent")
{
Toaster.l(getActivity(),"resultEvent Occurred");
}
}
@Override
public void onEventError(Exception e) {
Toaster.l(getActivity(),"Event Error Occurred : " + e.getMessage());
}
};
ScruffR
February 22, 2016, 9:46am
2
Is the string you are looking for not just another field of particleEvent
rather than of the Android event?
wwy
February 22, 2016, 10:01am
3
The eventName string is not contained within ParticleEvent unfortunately. I’m not sure why it isn’t - it would be a good idea, in my mind. If it was, I could simply extract it and ignore the String parameter.
This is the ParticleEvent declaration:
package io.particle.android.sdk.cloud;
import com.google.gson.annotations.SerializedName;
import java.util.Date;
import javax.annotation.ParametersAreNonnullByDefault;
// Normally it's bad form to use network data models as API data models, but considering that
// for the moment, they'd be a 1:1 mapping, we'll just reuse this data model class. If the
// network API changes, then we can write new classes for the network API models, without
// impacting the public API of the SDK.
@ParametersAreNonnullByDefault
public class ParticleEvent {
@SerializedName("coreid")
public final String deviceId;
@SerializedName("data")
This file has been truncated. show original
wwy
February 22, 2016, 9:30pm
6
wwy
February 23, 2016, 10:42am
7
Modifying the AuthenticatedSseEventStream.java file looks messy.
The best solution is probably to include the eventName in the data. i.e. add an eventName String to the ParticleEvent class