Halyri - Häke  0.9
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
Hake_WPF.Connection Class Reference

Handles communication between server and this client. User must use connect method to connect server. After that user can use rest of the methods to manage connection. Also user should handle most of events, but atleast connectionupdatedevent. More...

Public Member Functions

delegate void AssigmentUpdated (ObservableCollection< Assignment > newConnections)
 Invoked when connection is updated. More...
 
 Connection (String username, String password)
 Creates connection with credentials provided. More...
 
ObservableCollection< AssignmentConnect (String endpointAddress)
 Creates receiver and connects to server with wcf and udp. More...
 
bool UdpSendMedia (MediaInformation mediaInfo, byte[] data, int originalLength)
 Sends media to the server using the active UdpMediaClientSocket instance. Returns true, is the data is successfully queued for sending, otherwise returns false. More...
 
void ChangePriority (Assignment assignment, Assignment.priorities priority)
 Chances priority to currentconnetion and then updates that to connectionslist and finaly to server. It makes the connection in new thread so it won't block ui thread. More...
 
ObservableCollection< AssignmentConvertConnectionsToAssigments (ConnectionDto[] Connections)
 Converts ConnectionDto to Assignment. If location is not set, uses null and do not assign accuracymeters or time from location. If device info is empty, uses empty DeviceInfoDto. More...
 
void RequestAction (RemoteActionDto action)
 Requests action for current userconnection for currentconnection with given action. CurrentConnection needed or this does nothing. More...
 
void RequestMeasurementData (MeasurementInstrumentDto instrument)
 If there is currentconnection requests measurements data start from server with given instrument. More...
 
void CancelMeasurementData (MeasurementInstrumentDto instrument)
 Cancel request to server to stop measurement data sending. Current connection is needed for this. More...
 
bool IsConnected ()
 Is Connection on. More...
 
ObservableCollection< AssignmentGetAllConnections ()
 Should be used only one time to save localy and then use ActiveConnectionsUpdated to update those. Userconnection and converts server response to assignment list. More...
 
bool Reconnect ()
 Reconnects to server. More...
 
bool Disconnect ()
 Disconnects from server. More...
 
void ProcessAssignment (object assignment)
 Changes assignments state to in progress to server. First it search right connection using guid and then makes the connection currentconnection. More...
 
void SendTextMessage (String message)
 Makes new thread to send message to server so it won't block ui thread. More...
 
void RequestAudioVideoMedia ()
 Makes new thread to request audio video so it won't block ui thread. More...
 
void CancelAudioVideoMedia ()
 Makes new thread to request cancel of audio and video so it won't block ui thread. More...
 
async Task PingAsync (int interval)
 Sends a keepalive message to server More...
 

Public Attributes

UdpMediaDataReceived UdpMediaDataReceivedEvent
 

Properties

AsyncReceiver receiver [get, set]
 Gets and sets AsyncReceiver. More...
 

Events

AssigmentUpdated AssigmentUpdatedEvent
 

Private Member Functions

void InitializeUdpClient ()
 Initializes a new UdpMediaClientSocket instance for media transfer from and to the server. More...
 
void UdpMediaPacketReceivedHandler (object sender, MediaPacket mediaPacket)
 Handles incoming media packet events from the active UdpMediaClientSocket instance. Republishes them as UdpMediaDataReceivedEvent. More...
 
void UdpSocketFailedEventHandler (object sender)
 Handles failure events of the active UdpMediaClientSocket. Currently only writes this information to the debug. More...
 
void ChangePriorityThread (object priority)
 If there is no current connection this will not do anything. If there is it changes current connections priorit and send it to server. More...
 
void receiver_ConnectionsUpdatedEvent (ConnectionDto[] newConnections)
 Handles when connectionupdates are received. Updates connectionslist and invokes event for update with connectiondto's converted to assignments. More...
 
void UpdateConnectionsList (ConnectionDto[] newConnections)
 Replaces connections with new connections by comparing their guid. If there is no connection with that guid, adds new connection. More...
 
void SendMessage (object message)
 Send message to server. More...
 
void RequestAudioVideoMediaThread ()
 Makes request to server for audio and video with hardcoded specs in exampleMediaConfiguration. More...
 
void CancelAudioVideoMediaThread ()
 Request cancel to audio and video from server. It is done by mediaConfigurationdto and setting enableaudio and enablepicture to false. More...
 

Private Attributes

const int udpServerPort = 15103
 
const string udpServerIp = "130.234.9.165"
 
WcfCallCenterServiceClient client
 
string guid
 
InstanceContext context
 
CallCenterConnectionDto userConnection
 
ObservableCollection
< ConnectionDto
connectionDtos = new ObservableCollection<ConnectionDto>()
 
ConnectionDto currentConnection
 
UserCredentialsDto userCredentialsDto
 
UdpMediaClientSocket udpSocket
 
bool isConnected = false
 

Detailed Description

Handles communication between server and this client. User must use connect method to connect server. After that user can use rest of the methods to manage connection. Also user should handle most of events, but atleast connectionupdatedevent.

<author>Atte Söderlund</author>

Constructor & Destructor Documentation

Hake_WPF.Connection.Connection ( String  username,
String  password 
)

Creates connection with credentials provided.

Parameters
usernameUsername that connection uses
passwordPassword that connection uses

Member Function Documentation

delegate void Hake_WPF.Connection.AssigmentUpdated ( ObservableCollection< Assignment newConnections)

Invoked when connection is updated.

Parameters
newConnectionsConnections as Assignments
void Hake_WPF.Connection.CancelAudioVideoMedia ( )

Makes new thread to request cancel of audio and video so it won't block ui thread.

void Hake_WPF.Connection.CancelAudioVideoMediaThread ( )
private

Request cancel to audio and video from server. It is done by mediaConfigurationdto and setting enableaudio and enablepicture to false.

void Hake_WPF.Connection.CancelMeasurementData ( MeasurementInstrumentDto  instrument)

Cancel request to server to stop measurement data sending. Current connection is needed for this.

<author>Niko Mononen</author>

Parameters
instrumentInstrument that is sending the data
void Hake_WPF.Connection.ChangePriority ( Assignment  assignment,
Assignment.priorities  priority 
)

Chances priority to currentconnetion and then updates that to connectionslist and finaly to server. It makes the connection in new thread so it won't block ui thread.

Parameters
assignmentAssignment that needs updating
priorityPriority that assignment is to bee changed.
void Hake_WPF.Connection.ChangePriorityThread ( object  priority)
private

If there is no current connection this will not do anything. If there is it changes current connections priorit and send it to server.

Parameters
priorityNew priority
ObservableCollection<Assignment> Hake_WPF.Connection.Connect ( String  endpointAddress)

Creates receiver and connects to server with wcf and udp.

Returns
ObservableCollection of connections as assignments.
ObservableCollection<Assignment> Hake_WPF.Connection.ConvertConnectionsToAssigments ( ConnectionDto[]  Connections)

Converts ConnectionDto to Assignment. If location is not set, uses null and do not assign accuracymeters or time from location. If device info is empty, uses empty DeviceInfoDto.

Parameters
ConnectionConnectionDto that needs converting to Assigment
Returns
Converted Assigment
bool Hake_WPF.Connection.Disconnect ( )

Disconnects from server.

Returns
True when disconnect goes without error and false if there is any error.
ObservableCollection<Assignment> Hake_WPF.Connection.GetAllConnections ( )

Should be used only one time to save localy and then use ActiveConnectionsUpdated to update those. Userconnection and converts server response to assignment list.

Returns
ObservableCollection of all connections as Assignment
void Hake_WPF.Connection.InitializeUdpClient ( )
private

Initializes a new UdpMediaClientSocket instance for media transfer from and to the server.

bool Hake_WPF.Connection.IsConnected ( )

Is Connection on.

Returns
Boolean of is connection established.
async Task Hake_WPF.Connection.PingAsync ( int  interval)

Sends a keepalive message to server

<author>Ilkka Rautiainen</author>

Parameters
intervalping interval in seconds
Returns
task
void Hake_WPF.Connection.ProcessAssignment ( object  assignment)

Changes assignments state to in progress to server. First it search right connection using guid and then makes the connection currentconnection.

Parameters
assignmentAssignment that is to be set as in progress
void Hake_WPF.Connection.receiver_ConnectionsUpdatedEvent ( ConnectionDto[]  newConnections)
private

Handles when connectionupdates are received. Updates connectionslist and invokes event for update with connectiondto's converted to assignments.

Parameters
newConnectionsNew connections
bool Hake_WPF.Connection.Reconnect ( )

Reconnects to server.

Returns
True when reconnect goes without error and false if there is any error.
void Hake_WPF.Connection.RequestAction ( RemoteActionDto  action)

Requests action for current userconnection for currentconnection with given action. CurrentConnection needed or this does nothing.

Parameters
actionWhat user wants action to be
void Hake_WPF.Connection.RequestAudioVideoMedia ( )

Makes new thread to request audio video so it won't block ui thread.

void Hake_WPF.Connection.RequestAudioVideoMediaThread ( )
private

Makes request to server for audio and video with hardcoded specs in exampleMediaConfiguration.

void Hake_WPF.Connection.RequestMeasurementData ( MeasurementInstrumentDto  instrument)

If there is currentconnection requests measurements data start from server with given instrument.

<author>Niko Mononen</author>

Parameters
instrumentInstrument that provides data
void Hake_WPF.Connection.SendMessage ( object  message)
private

Send message to server.

Parameters
messageMessage to be send
void Hake_WPF.Connection.SendTextMessage ( String  message)

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

Parameters
messageMessage to be send
void Hake_WPF.Connection.UdpMediaPacketReceivedHandler ( object  sender,
MediaPacket  mediaPacket 
)
private

Handles incoming media packet events from the active UdpMediaClientSocket instance. Republishes them as UdpMediaDataReceivedEvent.

Parameters
senderUdpMediaDataReceivedEvent event punlishing this event
mediaPacketThe received MediaPacket instance
bool Hake_WPF.Connection.UdpSendMedia ( MediaInformation  mediaInfo,
byte[]  data,
int  originalLength 
)

Sends media to the server using the active UdpMediaClientSocket instance. Returns true, is the data is successfully queued for sending, otherwise returns false.

Parameters
mediaInfoDescription of the media
dataBytes constituting the media data
originalLengthLength of the media prior to encoding for such encodings that require the length for decompression.
Returns
True, if data queued for sending, otherwise false
void Hake_WPF.Connection.UdpSocketFailedEventHandler ( object  sender)
private

Handles failure events of the active UdpMediaClientSocket. Currently only writes this information to the debug.

Parameters
senderUdpMediaClientSocket instance sending the event
void Hake_WPF.Connection.UpdateConnectionsList ( ConnectionDto[]  newConnections)
private

Replaces connections with new connections by comparing their guid. If there is no connection with that guid, adds new connection.

Parameters
newConnectionsNew connetions

Member Data Documentation

WcfCallCenterServiceClient Hake_WPF.Connection.client
private
ObservableCollection<ConnectionDto> Hake_WPF.Connection.connectionDtos = new ObservableCollection<ConnectionDto>()
private
InstanceContext Hake_WPF.Connection.context
private
ConnectionDto Hake_WPF.Connection.currentConnection
private
string Hake_WPF.Connection.guid
private
bool Hake_WPF.Connection.isConnected = false
private
UdpMediaDataReceived Hake_WPF.Connection.UdpMediaDataReceivedEvent
const string Hake_WPF.Connection.udpServerIp = "130.234.9.165"
private
const int Hake_WPF.Connection.udpServerPort = 15103
private
UdpMediaClientSocket Hake_WPF.Connection.udpSocket
private
CallCenterConnectionDto Hake_WPF.Connection.userConnection
private
UserCredentialsDto Hake_WPF.Connection.userCredentialsDto
private

Property Documentation

AsyncReceiver Hake_WPF.Connection.receiver
getset

Gets and sets AsyncReceiver.

Event Documentation

AssigmentUpdated Hake_WPF.Connection.AssigmentUpdatedEvent

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