Halyri - Mobiili  0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
Halyri.Connection Class Reference

Makes all connection actions to server. User can connect, update information about device, personalinfo, medicalinfo or location. Uses SignalR for receiving and WCF for sending. More...

Public Member Functions

delegate void MediaConfigurationRequestUpdated (object sender, EventArgs e, MediaConfigurationDto config)
 Invoked when media configuration update is requested. More...
 
delegate void Connected ()
 Invoked when connected More...
 
delegate void InProcess ()
 Invoked when connection is taken to process. More...
 
delegate void Processed ()
 Invoked when connection is processed. More...
 
delegate void OpenMapRequest ()
 Invoked when map is requested to open. More...
 
delegate void CloseMapRequest ()
 Invoked when map is requested to close. More...
 
delegate void TextMessageReceived (String message)
 Invoked when there is textmessage received. More...
 
delegate void MeasurementStartRequestReceived (MeasurementInstrumentDto instrument)
 Invoked when measurement data is requested to start with given instrument. More...
 
delegate void MeasurementStopRequestReceived (MeasurementInstrumentDto instrument)
 Invoked when measurement sending is requested to stop with given instrument. More...
 
delegate void MeasurementInstrumentListRequestReceived ()
 Invoked when received request for measurement instrument list. More...
 
delegate void ConnectionFailed ()
 Invoked when connection has failed. More...
 
 Connection ()
 Constructor that does nothing. More...
 
bool Connect (UpdateConnectionPriorityRequest priority)
 Connects signalR and wcf with given priority and stores guid. Updates personalinfo, location and device info. More...
 
void StartGpsTracking ()
 Starts Gps tracking with DesiredAccuracy high ad MovementThreshold as assigned. Basicly when phone moves MovementThreshold amount, this is invoked. More...
 
void Disconnect ()
 Disconnects. More...
 
void Reconnect (UpdateConnectionPriorityRequest priority)
 Reconnects with given priority. More...
 
void UdpConnect ()
 Connects udp. More...
 
void UdpDisconnect ()
 Disconnects udp. More...
 
bool UdpMediaSend (MediaInformation mediaInfo, byte[] mediaData, int originalLength)
 Sends media with udp. More...
 
void UpdatePriority (UpdateConnectionPriorityRequest priority)
 Adds guid to priority and then updates priority async. More...
 
void UpdateLocation (LocationTypeDto type)
 Adds guid to location and then updates location async. More...
 
void UpdatePersonalInfo (UpdatePersonalInfoRequest personalInfo)
 Adds guid to personalinfo and then updates personalinfo async. More...
 
void UpdateDeviceInfo (UpdateDeviceInfoRequest deviceInfo)
 Adds guid to deviceinfo and then updates deviceinfo async. More...
 
void UpdateMedicalInfo (UpdateMedicalInfoRequest medicalInfo)
 Adds guid to medicalinfo and then updates medicalinfo async. More...
 
void SendMessage (String message)
 Makes new thread to send message to server so it won't block ui thread. More...
 
void SwitchNoSound (bool value)
 Switch nosound. More...
 
void UpdateLocationUserSpecified (System.Device.Location.GeoCoordinate coordinates)
 Updates Location with given goordinates as user specific type. More...
 
void sendMedia (MediaInformationDto info, byte[] data, object userState)
 Sends media packet over the WCF connection to the server. More...
 
void UpdateMeasurementInstrumentList (ObservableCollection< MeasurementInstrumentDto > instrumentList)
 Updates the provided list of measurement instruments to the server. More...
 
void UploadMeasurementInstrumentData (MeasurementInstrumentDto instrument, byte[] data)
 Uploads the provided instrument data from the specified instrument to the server. More...
 
void UpdateEmergencyType (string emergencyType)
 Updates EmergencyType. More...
 

Public Attributes

MediaConfigurationRequestUpdated MediaConfigurationUpdatedEvent
 
MediaSendFinishedDelegate MediaSendFinishedEvent
 
UdpMediaDataReceived UdpMediaDataReceivedEvent
 
MediaSocketHasFailed MediaSocketHasFailedEvent
 

Events

Connected ConnectedEvent
 
InProcess InProcessEvent
 
Processed ProcessedEvent
 
OpenMapRequest OpenMapRequestEvent
 
CloseMapRequest CloseMapRequestEvent
 
TextMessageReceived TextMessageReceivedEvent
 
MeasurementStartRequestReceived MeasurementStartRequestReceivedEvent
 
MeasurementStopRequestReceived MeasurementStopRequestReceivedEvent
 
MeasurementInstrumentListRequestReceived MeasurementInstrumentListRequestReceivedEvent
 
ConnectionFailed ConnectionFailedEvent
 

Private Member Functions

void UdpMediaPacketReceivedHandler (Object sender, MediaPacket media)
 Invoked when UdpMediaPacket is received and then invokes UdpMediaDataReceivedEvent. More...
 
void UdpMediaSocketHasFaildedHandler (Object sender)
 Invoked when udp media socket has failed. Invokes only MediaSocektHasFailedEvent. More...
 
async Task ConnectSignalR ()
 Sends connect invoke to server and stores guid. More...
 
async Task InitializeSignalR ()
 Creates signalR hub and connects to it. Writes to debug if connects and creates proxy.on for location request. More...
 
void connection_Received (string obj)
 Writes received obj to debug. More...
 
async Task GetLocation ()
 Gets phones location with high accuracy. If location is disabled shows aboutpromt in ui thread. Writes errors to debug. More...
 
void ShowAboutPromtThread ()
 Ui thread for showing aboutpromt that location is set disabled. Uses custom ok button. More...
 
void Connection_Click (object sender, RoutedEventArgs e)
 For aboutpromts custom ok button. Closes aboutPromt. More...
 
void geolocator_PositionChanged (Geolocator sender, PositionChangedEventArgs args)
 When phone is moved and this event is invoked -> updates location to server. More...
 
void SendMessageThread (object message)
 Sends given message to server. More...
 
void ClientUploadMediaSegmentCompleted (object sender, AsyncCompletedEventArgs e)
 Handles async media packet WCF uploading completed events. Republishes the event as MediaSendFinishedDelegate. More...
 

Private Attributes

bool connected = false
 
WcfMobileServiceClient client
 
String guid = ""
 
const string udpServerAddress = "130.234.9.165"
 
const int udpServerPort = 15103
 
const String SERVERADDRESS = "http://130.234.9.165:15100/HalyriServer/"
 
const string WCFADDRESS = "http://130.234.9.165:15100/HalyriServer/services/WcfMobileService.svc"
 
const String HUBPUBLICNAME = "SignalRMobileHub"
 
const String CONNECTMETHODNAME = "connect"
 
const string LOCATIONREQUESTEDMETHODNAME = "RequestLocationUpdate"
 
const String DISPLAYUSERLOCATIONMAP = "DisplayUserLocationMap"
 
const String CLOSEUSERLOCATIONMAP = "CloseUserLocationMap"
 
const String UPDATECONNECTIONSTATUS = "UpdateConnectionStatus"
 
const String INCOMINGTEXTMESSAGE = "IncomingTextMessage"
 
const string MEDIASTREAMINGMETHOD = "RequestMediaUpstreaming"
 
const string INSTRUMENTLISTREQUESTMETHOD = "GetInstrumentList"
 
const string MEASUREMENTSTARTREQUESTMETOD = "RequestStartMeasurement"
 
const string MEASUREMENTSTOPREQUESTMETOD = "RequestStopMeasurement"
 
const String DISCONNECTMETHODNAME = "Disconnect"
 
const String RECONNECTMETHODNAME = "Reconnect"
 
IHubProxy proxy
 
Settings settings = new Settings()
 
UdpMediaClientSocket udpSocket
 
Geocoordinate coordinates
 
const int movementThreasHoldForGeoLocator = 10
 
Geolocator geolocator
 
AboutPrompt aboutPrompt
 

Detailed Description

Makes all connection actions to server. User can connect, update information about device, personalinfo, medicalinfo or location. Uses SignalR for receiving and WCF for sending.

<author>Atte Söderlund</author>

Constructor & Destructor Documentation

Halyri.Connection.Connection ( )

Constructor that does nothing.

Member Function Documentation

void Halyri.Connection.ClientUploadMediaSegmentCompleted ( object  sender,
AsyncCompletedEventArgs  e 
)
private

Handles async media packet WCF uploading completed events. Republishes the event as MediaSendFinishedDelegate.

<author>Veli-Mikko Puupponen</author>

Parameters
senderThe sending object
eAsync call completed event args
delegate void Halyri.Connection.CloseMapRequest ( )

Invoked when map is requested to close.

bool Halyri.Connection.Connect ( UpdateConnectionPriorityRequest  priority)

Connects signalR and wcf with given priority and stores guid. Updates personalinfo, location and device info.

Parameters
priorityPriority
delegate void Halyri.Connection.Connected ( )

Invoked when connected

void Halyri.Connection.Connection_Click ( object  sender,
RoutedEventArgs  e 
)
private

For aboutpromts custom ok button. Closes aboutPromt.

void Halyri.Connection.connection_Received ( string  obj)
private

Writes received obj to debug.

Parameters
objReceived string
delegate void Halyri.Connection.ConnectionFailed ( )

Invoked when connection has failed.

async Task Halyri.Connection.ConnectSignalR ( )
private

Sends connect invoke to server and stores guid.

void Halyri.Connection.Disconnect ( )

Disconnects.

void Halyri.Connection.geolocator_PositionChanged ( Geolocator  sender,
PositionChangedEventArgs  args 
)
private

When phone is moved and this event is invoked -> updates location to server.

async Task Halyri.Connection.GetLocation ( )
private

Gets phones location with high accuracy. If location is disabled shows aboutpromt in ui thread. Writes errors to debug.

Returns
Taks from async operation
async Task Halyri.Connection.InitializeSignalR ( )
private

Creates signalR hub and connects to it. Writes to debug if connects and creates proxy.on for location request.

delegate void Halyri.Connection.InProcess ( )

Invoked when connection is taken to process.

delegate void Halyri.Connection.MeasurementInstrumentListRequestReceived ( )

Invoked when received request for measurement instrument list.

delegate void Halyri.Connection.MeasurementStartRequestReceived ( MeasurementInstrumentDto  instrument)

Invoked when measurement data is requested to start with given instrument.

Parameters
instrumentInstrument
delegate void Halyri.Connection.MeasurementStopRequestReceived ( MeasurementInstrumentDto  instrument)

Invoked when measurement sending is requested to stop with given instrument.

Parameters
instrumentInstrument
delegate void Halyri.Connection.MediaConfigurationRequestUpdated ( object  sender,
EventArgs  e,
MediaConfigurationDto  config 
)

Invoked when media configuration update is requested.

Parameters
config
delegate void Halyri.Connection.OpenMapRequest ( )

Invoked when map is requested to open.

delegate void Halyri.Connection.Processed ( )

Invoked when connection is processed.

void Halyri.Connection.Reconnect ( UpdateConnectionPriorityRequest  priority)

Reconnects with given priority.

Parameters
priorityPriority
void Halyri.Connection.sendMedia ( MediaInformationDto  info,
byte[]  data,
object  userState 
)

Sends media packet over the WCF connection to the server.

<author>Veli-Mikko Puupponen</author>

Parameters
infoInformation describing the media
dataMedia data
userStateUser state object for tracking corresponding async operation completed event for this send call
void Halyri.Connection.SendMessage ( String  message)

Makes new thread to send message to server so it won't block ui thread.

Parameters
messageMessage
void Halyri.Connection.SendMessageThread ( object  message)
private

Sends given message to server.

Parameters
messageMessage
void Halyri.Connection.ShowAboutPromtThread ( )
private

Ui thread for showing aboutpromt that location is set disabled. Uses custom ok button.

void Halyri.Connection.StartGpsTracking ( )

Starts Gps tracking with DesiredAccuracy high ad MovementThreshold as assigned. Basicly when phone moves MovementThreshold amount, this is invoked.

void Halyri.Connection.SwitchNoSound ( bool  value)

Switch nosound.

Parameters
valueValue to where to switch
delegate void Halyri.Connection.TextMessageReceived ( String  message)

Invoked when there is textmessage received.

Parameters
messageReceived message
void Halyri.Connection.UdpConnect ( )

Connects udp.

<author>Veli-Mikko Puupponen</author>

void Halyri.Connection.UdpDisconnect ( )

Disconnects udp.

<author>Veli-Mikko Puupponen</author>

void Halyri.Connection.UdpMediaPacketReceivedHandler ( Object  sender,
MediaPacket  media 
)
private

Invoked when UdpMediaPacket is received and then invokes UdpMediaDataReceivedEvent.

<author>Veli-Mikko Puupponen</author>

bool Halyri.Connection.UdpMediaSend ( MediaInformation  mediaInfo,
byte[]  mediaData,
int  originalLength 
)

Sends media with udp.

<author>Veli-Mikko Puupponen</author>

Parameters
mediaInfoMedia information
mediaDataData
originalLengthLenght
Returns
void Halyri.Connection.UdpMediaSocketHasFaildedHandler ( Object  sender)
private

Invoked when udp media socket has failed. Invokes only MediaSocektHasFailedEvent.

<author>Veli-Mikko Puupponen</author>

void Halyri.Connection.UpdateDeviceInfo ( UpdateDeviceInfoRequest  deviceInfo)

Adds guid to deviceinfo and then updates deviceinfo async.

Parameters
deviceInfoDeviceinfo to update
void Halyri.Connection.UpdateEmergencyType ( string  emergencyType)

Updates EmergencyType.

Parameters
emergencyTypeType
void Halyri.Connection.UpdateLocation ( LocationTypeDto  type)

Adds guid to location and then updates location async.

Parameters
locationLocation to update
void Halyri.Connection.UpdateLocationUserSpecified ( System.Device.Location.GeoCoordinate  coordinates)

Updates Location with given goordinates as user specific type.

Parameters
coordinatesGoordinates
void Halyri.Connection.UpdateMeasurementInstrumentList ( ObservableCollection< MeasurementInstrumentDto instrumentList)

Updates the provided list of measurement instruments to the server.

<author>Niko Mononen</author>

Parameters
instrumentListList of available measurement instruments on the device
void Halyri.Connection.UpdateMedicalInfo ( UpdateMedicalInfoRequest  medicalInfo)

Adds guid to medicalinfo and then updates medicalinfo async.

Parameters
medicalInfoMedicalinfo to update
void Halyri.Connection.UpdatePersonalInfo ( UpdatePersonalInfoRequest  personalInfo)

Adds guid to personalinfo and then updates personalinfo async.

Parameters
personalInfoPersonalinfo to update
void Halyri.Connection.UpdatePriority ( UpdateConnectionPriorityRequest  priority)

Adds guid to priority and then updates priority async.

Parameters
priorityPriority to update
void Halyri.Connection.UploadMeasurementInstrumentData ( MeasurementInstrumentDto  instrument,
byte[]  data 
)

Uploads the provided instrument data from the specified instrument to the server.

<author>Niko Mononen</author>

Parameters
instrumentSource instrument of the measurement data
dataData provided by the instrument

Member Data Documentation

AboutPrompt Halyri.Connection.aboutPrompt
private
WcfMobileServiceClient Halyri.Connection.client
private
const String Halyri.Connection.CLOSEUSERLOCATIONMAP = "CloseUserLocationMap"
private
bool Halyri.Connection.connected = false
private
const String Halyri.Connection.CONNECTMETHODNAME = "connect"
private
Geocoordinate Halyri.Connection.coordinates
private
const String Halyri.Connection.DISCONNECTMETHODNAME = "Disconnect"
private
const String Halyri.Connection.DISPLAYUSERLOCATIONMAP = "DisplayUserLocationMap"
private
Geolocator Halyri.Connection.geolocator
private
Initial value:
= new Geolocator() { DesiredAccuracy=PositionAccuracy.Default,MovementThreshold=movementThreasHoldForGeoLocator,
ReportInterval=10000}
String Halyri.Connection.guid = ""
private
const String Halyri.Connection.HUBPUBLICNAME = "SignalRMobileHub"
private
const String Halyri.Connection.INCOMINGTEXTMESSAGE = "IncomingTextMessage"
private
const string Halyri.Connection.INSTRUMENTLISTREQUESTMETHOD = "GetInstrumentList"
private
const string Halyri.Connection.LOCATIONREQUESTEDMETHODNAME = "RequestLocationUpdate"
private
const string Halyri.Connection.MEASUREMENTSTARTREQUESTMETOD = "RequestStartMeasurement"
private
const string Halyri.Connection.MEASUREMENTSTOPREQUESTMETOD = "RequestStopMeasurement"
private
MediaConfigurationRequestUpdated Halyri.Connection.MediaConfigurationUpdatedEvent
MediaSendFinishedDelegate Halyri.Connection.MediaSendFinishedEvent
MediaSocketHasFailed Halyri.Connection.MediaSocketHasFailedEvent
const string Halyri.Connection.MEDIASTREAMINGMETHOD = "RequestMediaUpstreaming"
private
const int Halyri.Connection.movementThreasHoldForGeoLocator = 10
private
IHubProxy Halyri.Connection.proxy
private
const String Halyri.Connection.RECONNECTMETHODNAME = "Reconnect"
private
const String Halyri.Connection.SERVERADDRESS = "http://130.234.9.165:15100/HalyriServer/"
private
Settings Halyri.Connection.settings = new Settings()
private
UdpMediaDataReceived Halyri.Connection.UdpMediaDataReceivedEvent
const string Halyri.Connection.udpServerAddress = "130.234.9.165"
private
const int Halyri.Connection.udpServerPort = 15103
private
UdpMediaClientSocket Halyri.Connection.udpSocket
private
const String Halyri.Connection.UPDATECONNECTIONSTATUS = "UpdateConnectionStatus"
private
const string Halyri.Connection.WCFADDRESS = "http://130.234.9.165:15100/HalyriServer/services/WcfMobileService.svc"
private

Event Documentation

CloseMapRequest Halyri.Connection.CloseMapRequestEvent
Connected Halyri.Connection.ConnectedEvent
ConnectionFailed Halyri.Connection.ConnectionFailedEvent
InProcess Halyri.Connection.InProcessEvent
MeasurementInstrumentListRequestReceived Halyri.Connection.MeasurementInstrumentListRequestReceivedEvent
MeasurementStartRequestReceived Halyri.Connection.MeasurementStartRequestReceivedEvent
MeasurementStopRequestReceived Halyri.Connection.MeasurementStopRequestReceivedEvent
OpenMapRequest Halyri.Connection.OpenMapRequestEvent
Processed Halyri.Connection.ProcessedEvent
TextMessageReceived Halyri.Connection.TextMessageReceivedEvent

The documentation for this class was generated from the following file: