Beispiel #1
0
        void OnDataReceive(IAsyncResult result)
        {
            TuringMessageState state = (TuringMessageState)result.AsyncState;

            try
            {
                int bytesRead = state.Source._Socket.EndReceive(result);
                if (bytesRead > 0)
                {
                    TuringMessage msg = state.CheckData(bytesRead);
                    if (msg != null)
                    {
                        RaiseOnMessage(state.Source, msg);
                    }
                    ReadMessageAsync(state);
                }
            }
            catch// (Exception e)
            {
                state.Source.Dispose();
            }
        }
Beispiel #2
0
 /// <summary>
 /// Read Message sync
 /// </summary>
 static void ReadMessageAsync(TuringMessageState state)
 {
     state.Source._Socket.BeginReceive(state.Buffer, state.Index, state.Buffer.Length - state.Index, 0, state.Source.OnDataReceive, state);
 }