C# Class Particle.ParticleEventManager

This class is used to manage the stream of events from the Particle Cloud and Turn them into native .net events
显示文件 Open project: ParticleNET/ParticleSDK Class Usage Examples

Protected Properties

Property Type Description
_stop bool

Public Methods

Method Description
ParticleEventManager ( Uri streamUri, String accessToken ) : Newtonsoft.Json

Initializes a new instance of the ParticleEventManager class.

Start ( ) : void

Starts listening to the events coming in from the specified stream

Stop ( ) : void

Stops listening to the event stream

Protected Methods

Method Description
ConnectToClient ( ) : System.Threading.Tasks.Task

Connects to client.

ListensToStreamAsync ( Stream eventStream ) : System.Threading.Tasks.Task

Listenses to stream for Web Events

ParticleEventManager ( ) : Newtonsoft.Json

Initializes a new instance of the ParticleEventManager class. Without requiring the Access Token, or Uri mostly used for unit tests

fireEvent ( String eventName, ParticleEventData data ) : void

Fires the event.

Method Details

ConnectToClient() protected method

Connects to client.
protected ConnectToClient ( ) : System.Threading.Tasks.Task
return System.Threading.Tasks.Task

ListensToStreamAsync() protected method

Listenses to stream for Web Events
protected ListensToStreamAsync ( Stream eventStream ) : System.Threading.Tasks.Task
eventStream Stream The event stream.
return System.Threading.Tasks.Task

ParticleEventManager() protected method

Initializes a new instance of the ParticleEventManager class. Without requiring the Access Token, or Uri mostly used for unit tests
protected ParticleEventManager ( ) : Newtonsoft.Json
return Newtonsoft.Json

ParticleEventManager() public method

Initializes a new instance of the ParticleEventManager class.
public ParticleEventManager ( Uri streamUri, String accessToken ) : Newtonsoft.Json
streamUri System.Uri The stream URI. i.e. https://api.particle.io/v1/devices/events
accessToken String The access token for authentication.
return Newtonsoft.Json

Start() public method

Starts listening to the events coming in from the specified stream
public Start ( ) : void
return void

Stop() public method

Stops listening to the event stream
public Stop ( ) : void
return void

fireEvent() protected method

Fires the event.
protected fireEvent ( String eventName, ParticleEventData data ) : void
eventName String Name of the event.
data ParticleEventData The data.
return void

Property Details

_stop protected_oe property

Used to determen if we should keep running. If this is false we keep restarting and connecting to the event service If this is true stop listening to the event service
protected bool _stop
return bool