Example #1
0
 public Client(string sessionId,Guid userId, IClientProxy clientProxy, Language language)
 {
     this._SessionId = sessionId;
     this._UserId = userId;
     this._ClientProxy = clientProxy;
     this._Language = language;
     this._MessageRelayEngine = new RelayEngine<Message>(this.SendMessage, this.HandlEngineException);
 }
 public ExchangeSystem(ExchangeSystemSetting exchangeSystemSetting, ConnectionManager connectionManager)
 {
     this._ExchangeSystemSetting = exchangeSystemSetting;
     this._ConnectionManager = connectionManager;
     this._CommandRelayEngine = new RelayEngine<Command>(this.DispatchCommand, this.HandleEngineException);
     this._QuotationRelayEngine = new RelayEngine<List<GeneralQuotation>>(this.SetQuotation, this.HandleQuotationRelayEngineException);
     this._QuotationServer = new QuotationServer(exchangeSystemSetting);
 }
Example #3
0
 private void InternalStart(string managerAddress, string exchangeCode)
 {
     this._ManagerAddress = managerAddress;
     this._ExchangeCode   = exchangeCode;
     if (this._CommandRelayEngine == null)
     {
         this._CommandRelayEngine = new RelayEngine <Command>(null, this.HandlEngineException, this.SendCommand);
     }
     ThreadPool.QueueUserWorkItem(this.ConnectToManager);
 }
Example #4
0
 public static void AddEvent(TraceEventType eventType, string format, params object[] args)
 {
     lock (Logger._Lock)
     {
         if (Logger.LogEngine == null)
         {
             Logger.LogEngine = new RelayEngine<Log>(Logger.WriteLog, Logger.HandlEngineException);
         }
         Logger.LogEngine.AddItem(new Log { EventType = eventType, Format = format, Args = args });
     }
 }
        public void Start()
        {
            this._QuotationRelayEngine = new RelayEngine<string>(this.ProcessQuotation, delegate(Exception ex) { });

            this._NetworkStream = this._TcpClient.GetStream();
            Thread receiveDataThread = new Thread(delegate()
            {
                while (true)
                {
                    byte[] buffer = new byte[2];
                    if (!this.ReadAll(buffer))
                    {
                        this.Stop();
                        break;
                    }
                    int packetLength = ((int)buffer[0]) * 256 + buffer[1];
                    if (packetLength <= 0) continue;
                    buffer = new byte[packetLength];

                    if (this.ReadAll(buffer))
                    {
                        try
                        {
                            this.Process(buffer);
                        }
                        catch (Exception e)
                        {
                            this.Stop();
                            Logger.TraceEvent(TraceEventType.Error, "QuotationClient.start ", e.ToString());
                        }
                    }
                    else
                    {
                        this.Stop();
                        break;
                    }
                }
            });
            receiveDataThread.IsBackground = true;
            receiveDataThread.Start();
        }
 public MessageClient()
 {
     this._MessageRelayEngine = new RelayEngine<Message>(this.ProcessMessage, this.HandleException);
 }
 public ExchangeSystem(ExchangeSystemSetting exchangeSystemSetting)
 {
     this._ExchangeSystemSetting = exchangeSystemSetting;
     this._CommandRelayEngine = new RelayEngine<Command>(this.Dispatch, this.HandlEngineException);
 }
 public MessageClient()
 {
     this._MessageRelayEngine = new RelayEngine<Message>(this.ProcessMessage, this.HandleException);
     this._MessageRelayEngine.Suspend();
     this._ExchangeDataManager = App.MainFrameWindow.ExchangeDataManager;
 }