-
Notifications
You must be signed in to change notification settings - Fork 1
/
GeolocationProvider.cs
59 lines (47 loc) · 1.54 KB
/
GeolocationProvider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Text;
using TcpLib;
namespace GeolocationTCP
{
public class GeolocationProvider : TcpServiceProvider
{
//private Geolocator loc = null;
//private TypedEventHandler<Geolocator, PositionChangedEventArgs> positionChangedHandler;
//private TypedEventHandler<Geolocator, StatusChangedEventArgs> statusChangedHandler;
//private MainWindow window = null;
private ConnectionState connection = null;
public GeolocationProvider()
{
}
public override object Clone()
{
return new GeolocationProvider();
}
public void Report(string nmea)
{
//FIXME from time to time throws ObjectDisposed
Boolean sent = connection.Write(Encoding.UTF8.GetBytes(nmea), 0, nmea.Length);
//if (!sent)
//{
// try
// {
// state.EndConnection(); //if write fails... then close connection
// }
// catch (Exception ex)
// {
// Console.WriteLine(ex.ToString());
// }
//}
}
public override void OnAcceptConnection(ConnectionState state)
{
connection = state;
}
public override void OnReceiveData(ConnectionState state)
{
}
public override void OnDropConnection(ConnectionState state)
{
}
}
}