Exemplo n.º 1
0
        /// <summary>
        /// Handles a callback from the listener socket and passes it along to any subscribers
        /// </summary>
        /// <param name="result">Callback result</param>
        private void ReceiveCompletedCallback(IAsyncResult result)
        {
            //Try-finally block will ensure that listener is "rebooted" no matter what happens
            try
            {
                IPEndPoint Endpoint       = new IPEndPoint(IPAddress.Any, _Port);
                byte[]     Result         = _Listener.EndReceive(result, ref Endpoint);
                string     ResultAsString = Encoding.UTF8.GetString(Result, 0, Result.Length);
                ResultAsString = ResultAsString.Trim('\0');

                if (TelexReceived != null)
                {
                    Telex Message = Telex.ParseReceivedMessage(ResultAsString);
                    TelexReceivedEventArgs EventArgs = new TelexReceivedEventArgs(Message);
                    TelexReceived(EventArgs);
                }
            }
            catch (Exception e)
            {
                throw new NotImplementedException();
            }
            finally
            {
                _Listener.BeginReceive(ReceiveCompletedCallback, null);
            }
        }
Exemplo n.º 2
0
 public TelexReceivedEventArgs(Telex telex)
 {
     TelexMessage = telex;
 }