Ejemplo n.º 1
0
        public Listener() : base(new ClientSettings()
        {
            EndPoint = new DnsEndPoint(
                AprsConfig.GetConfig().Uri,
                AprsConfig.GetConfig().Port),
            Listening             = false,
            Splitter              = "\r\n",
            Timeout               = 1020000, // 17 minutes afaik,
            ReconnectOnDisconnect = true
        })
        {
            // Set the callbacks before starting the client
            ConnectEvent += OnConnect;
            ReceiveEvent += OnReceive;

            Start();
        }
        public void Start()
        {
            if (_Socket != null)
            {
                Stop();
            }

            _Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            var state = new StateObject {
                WorkSocket = _Socket
            };

            _Socket.Connect(AprsConfig.GetConfig().URI, AprsConfig.GetConfig().Port);

            // Begin receiving the data from the remote device.
            _Socket.BeginReceive(state.Buffer, 0, StateObject.BUFFER_SIZE, 0, new AsyncCallback(ReceiveCallback), state);
            _Socket.Send(Encoding.ASCII.GetBytes(string.Format("user {0} pass {1} vers experimenting 0.1 filter {2}\n", AprsConfig.GetConfig().Callsign, AprsConfig.GetConfig().Password, AprsConfig.GetConfig().Filter)));
        }
Ejemplo n.º 3
0
 private void OnConnect()
 {
     Send(
         $"user {AprsConfig.GetConfig().Callsign} pass {AprsConfig.GetConfig().Password} vers experimenting 0.1 filter {AprsConfig.GetConfig().Filter}\n");
 }