internal void UDPReciever() { try { timerforchecklogin = new System.Timers.Timer(); timerforchecklogin.Interval = 30000; timerforchecklogin.Start(); timerforchecklogin.Elapsed += timerforchecklogin_Elapsed; Task.Factory.StartNew(() => { while (true) { // string address = subscriber.Receive (Encoding.Unicode); // byte[] buffer = new byte[512]; // int bufferSize = subscriber.Receive (buffer); var buffer = subscriber.Receive(); if (buffer == null) { this.OnDataStatusChange.Raise(OnDataStatusChange, OnDataStatusChange.CreateReadOnlyArgs("STOP")); continue; } FinalPrice _obj = (FinalPrice)DataPacket.RawDeserialize(buffer.Skip(4).Take(buffer.Length - 4).ToArray(), typeof(FinalPrice)); // Console.WriteLine("Received"); // if(_obj.Token==37454) // Console.Title="Token: "+_obj.Token+", Bid: "+_obj.MAXBID+", Ask: "+_obj.MINASK+" LTP: "+_obj.LTP; // else// if (_obj.Token==66039) // Console.WriteLine("Token {0} Bid {1} Ask {2} LTP {3}",_obj.Token,_obj.MAXBID,_obj.MINASK,_obj.LTP); if (_obj.Token == 111) { Console.WriteLine(" SomeThing Wrong in DATA Server"); this.OnDataStatusChange.Raise(OnDataStatusChange, OnDataStatusChange.CreateReadOnlyArgs("START")); // OnDataError.Invoke(); continue; } if (_iSubscribe.Contains(_obj.Token)) { this.OnDataStatusChange.Raise(OnDataStatusChange, OnDataStatusChange.CreateReadOnlyArgs("START")); OnDataArrived.Raise(OnDataArrived, OnDataArrived.CreateReadOnlyArgs(_obj)); } } }); } catch (OperationCanceledException e) { Console.WriteLine("Cancellation invoked"); } catch (AggregateException e) { Console.WriteLine("Some unexpected exception "); } catch (Exception Ex) { Console.WriteLine("Exception Raised " + Ex.StackTrace); } }
internal void UDPReciever() { try { timerforchecklogin = new System.Timers.Timer(); timerforchecklogin.Interval = 30000; timerforchecklogin.Start(); timerforchecklogin.Elapsed += timerforchecklogin_Elapsed; Task.Factory.StartNew(() => { while (true) { // string address = subscriber.Receive (Encoding.Unicode); // byte[] buffer = new byte[512]; // int bufferSize = subscriber.Receive (buffer); var buffer = subscriber.Receive(); if (buffer == null) { this.OnDataStatusChange.Raise(OnDataStatusChange, OnDataStatusChange.CreateReadOnlyArgs("STOP")); continue; } FinalPrice _obj = (FinalPrice)DataPacket.RawDeserialize(buffer.Skip(4).Take(buffer.Length - 4).ToArray(), typeof(FinalPrice)); if (_obj.Token == 111) { Console.WriteLine(" SomeThing Wrong in DATA Server"); this.OnDataStatusChange.Raise(OnDataStatusChange, OnDataStatusChange.CreateReadOnlyArgs("START")); // OnDataError.Invoke(); continue; } if (_iSubscribe.Contains(_obj.Token)) { UDP_RecieverData.Instance.TokenData.AddOrUpdate(_obj.Token, _obj, (k, v) => _obj); } } }); } catch (OperationCanceledException e) { Console.WriteLine("Cancellation invoked"); } catch (AggregateException e) { Console.WriteLine("Some unexpected exception "); } catch (Exception Ex) { Console.WriteLine("Exception Raised " + Ex.StackTrace); } }
void timerforchecklogin_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { try { if (_countolddatadata >= _countdata) { this.OnDataStatusChange.Raise(OnDataStatusChange, OnDataStatusChange.CreateReadOnlyArgs("STOP")); } else { this.OnDataStatusChange.Raise(OnDataStatusChange, OnDataStatusChange.CreateReadOnlyArgs("START")); _countolddatadata = _countdata; } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
internal void UDPReciever() { try { timerforchecklogin = new System.Timers.Timer(); timerforchecklogin.Interval = 30000; timerforchecklogin.Start(); timerforchecklogin.Elapsed += timerforchecklogin_Elapsed; Task.Factory.StartNew(() => { while (true) { // string address = subscriber.Receive (Encoding.Unicode); // byte[] buffer = new byte[512]; // int bufferSize = subscriber.Receive (buffer); var buffer = subscriber.Receive(); if (buffer == null) { this.OnDataStatusChange.Raise(OnDataStatusChange, OnDataStatusChange.CreateReadOnlyArgs("STOP")); continue; } //Data = (INTERACTIVE_ONLY_MBP)DataPacket.RawDeserialize(buffer.Skip(4).ToArray(), typeof(INTERACTIVE_ONLY_MBP)); long TokenName = BitConverter.ToInt64(buffer, 0); Data = (INTERACTIVE_ONLY_MBP)DataPacket.RawDeserialize(buffer.Skip(8).ToArray(), typeof(INTERACTIVE_ONLY_MBP)); OnDataChange.Raise(OnDataChange, OnDataChange.CreateReadOnlyArgs(Data)); //if (Global.Instance.Data_With_Nano.ContainsKey(TokenName)) //{ // switch(Global.Instance.Data_With_Nano[TokenName]) // { // case ClassType.MARKETWTCH: // Data = (INTERACTIVE_ONLY_MBP)DataPacket.RawDeserialize(buffer.Skip(8).ToArray(), typeof(INTERACTIVE_ONLY_MBP)); // OnDataChange.Raise(OnDataChange, OnDataChange.CreateReadOnlyArgs(Data)); // break; // case ClassType.SPREAD: // SpreadData_7211 = (MS_SPD_MKT_INFO_7211)DataPacket.RawDeserialize(buffer.Skip(8).ToArray(), typeof(MS_SPD_MKT_INFO_7211)); // OnSpreadDataChange.Raise(OnSpreadDataChange, OnSpreadDataChange.CreateReadOnlyArgs(SpreadData_7211)); // break; // } //} } }); } catch (OperationCanceledException e) { Console.WriteLine("Cancellation invoked"); } catch (AggregateException e) { Console.WriteLine("Some unexpected exception "); } catch (Exception Ex) { Console.WriteLine("Exception Raised " + Ex.StackTrace); } }