コード例 #1
0
ファイル: Subscription.cs プロジェクト: zeta1999/bemux
        public Subscription(string security, string fields, string options, CorrelationID correlationID)
        {
            if (security == null || security.Length <= 0 || security.IndexOf(TOPIC_OPTIONS_SEPARATOR) >= 0)
            {
                throw new ArgumentNullException("Invalid security: " + security);
            }
            if (options == null)
            {
                options = "";
            }
            if (fields == null)
            {
                fields = "";
            }
            if (fields.IndexOf(OPTIONS_SEPARATOR) >= 0)
            {
                throw new ArgumentException("Invalid fields: " + fields);
            }
            if (correlationID == null)
            {
                correlationID = new CorrelationID();
            }
            StringBuilder stringBuilder = new StringBuilder(security.Length + fields.Length + options.Length);

            stringBuilder.Append(security);
            bool flag  = fields.Length > 0;
            bool flag2 = options.Length > 0;

            if (flag || flag2)
            {
                stringBuilder.Append(TOPIC_OPTIONS_SEPARATOR);
                if (flag)
                {
                    stringBuilder.Append(FIELDS_OPTION);
                    stringBuilder.Append(fields);
                }
                if (flag && flag2)
                {
                    stringBuilder.Append(OPTIONS_SEPARATOR);
                }
                if (flag2)
                {
                    stringBuilder.Append(options);
                }
            }
            this.d_subscriptionString = stringBuilder.ToString();
            this.d_correlationId      = correlationID;



            this._security           = security;
            this._fields             = new List <string>(fields.Split(FIELDS_SEPARATOR).Select(s => Subscription.CheckField(s)));
            this._conflationInterval = this.ReadConflationInterval(new List <string>(options.Split(FIELDS_SEPARATOR)));
        }
コード例 #2
0
ファイル: Session.cs プロジェクト: zeta1999/bemux
        public CorrelationID SendRequest(Request request, CorrelationID correlationId)
        {
            if (request is HistoricalDataRequest.HistoricRequest)
            {
                if (!((HistoricalDataRequest.HistoricRequest)request).DtStart.HasValue)
                {
                    throw new ArgumentException("Historic requests must have start dates");
                }
            }

            request.correlationId = correlationId;
            this._sentRequests.Enqueue(request);
            return(correlationId);
        }
コード例 #3
0
ファイル: Subscription.cs プロジェクト: zeta1999/bemux
        public Subscription(string subscriptionString, CorrelationID correlationID, bool isResolved)
        {
            if (subscriptionString == null || correlationID == null)
            {
                throw new ArgumentNullException();
            }
            if (!Subscription.isValidSubscriptionString(subscriptionString))
            {
                throw new ArgumentException("An empty subscription string");
            }
            this.d_subscriptionString = subscriptionString;
            this.d_correlationId      = correlationID;
            this.d_isResolved         = isResolved;

            //set security and fields
        }
コード例 #4
0
    /*****************************************************************************
    *  Function    : GenerateToken
    *  Description : This function generate token using SessionOptions.AuthenticationOptions
    *             information.  Returns false on failure.
    *  Arguments   : reference token string
    *  Returns     : bool
    *****************************************************************************/
    private bool GenerateToken(out string token)
    {
        bool isTokenSuccess = false;
        bool isRunning      = false;

        token = string.Empty;
        CorrelationID tokenReqId      = new CorrelationID(99);
        EventQueue    tokenEventQueue = new EventQueue();

        d_session.GenerateToken(tokenReqId, tokenEventQueue);

        while (!isRunning)
        {
            Event eventObj = tokenEventQueue.NextEvent();
            if (eventObj.Type == Event.EventType.TOKEN_STATUS)
            {
                System.Console.WriteLine("processTokenEvents");
                foreach (Message msg in eventObj)
                {
                    System.Console.WriteLine(msg.ToString());
                    if (msg.MessageType == TOKEN_SUCCESS)
                    {
                        token          = msg.GetElementAsString("token");
                        isTokenSuccess = true;
                        isRunning      = true;
                        break;
                    }
                    else if (msg.MessageType == TOKEN_FAILURE)
                    {
                        System.Console.WriteLine("Received : " + TOKEN_FAILURE.ToString());
                        isRunning = true;
                        break;
                    }
                    else
                    {
                        System.Console.WriteLine("Error while Token Generation");
                        isRunning = true;
                        break;
                    }
                }
            }
        }

        return(isTokenSuccess);
    }
コード例 #5
0
ファイル: Session.cs プロジェクト: zeta1999/bemux
 public void Cancel(CorrelationID corr)
 {
     lock (this._syncroot) //protect _subscriptions
     {
         for (int i = this._subscriptions.Count - 1; i >= 0; i--)
         {
             if (this._subscriptions[i].CorrelationID.Value == corr.Value && this._subscriptions[i].CorrelationID.IsInternal == corr.IsInternal)
             {
                 MarketDataRequest.MarketEvent evtSubCancel = new MarketDataRequest.MarketEvent(Event.EventType.SUBSCRIPTION_STATUS, this._subscriptions[i]);
                 if (this._asyncHandler != null)
                 {
                     this._asyncHandler(evtSubCancel, this);
                 }
                 this._subscriptions.RemoveAt(i);
             }
         }
     }
 }
コード例 #6
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (!(obj is CorrelationID))
            {
                return(false);
            }
            CorrelationID correlationID = (CorrelationID)obj;

            if (this._corrType != correlationID._corrType)
            {
                return(false);
            }
            if (this.IsValue)
            {
                return(this._corrType == correlationID._corrType);
            }
            return(this._object.Equals(correlationID._object));
        }
コード例 #7
0
ファイル: Subscription.cs プロジェクト: zeta1999/bemux
        public Subscription(string security, IList <string> fields, IList <string> options, CorrelationID correlationID)
        {
            if (security == null || security.Length <= 0 || security.IndexOf(TOPIC_OPTIONS_SEPARATOR) >= 0)
            {
                throw new ArgumentNullException("Invalid security: " + security);
            }
            if (correlationID == null)
            {
                throw new ArgumentException("Null argument");
            }
            StringBuilder stringBuilder = new StringBuilder(64);

            stringBuilder.Append(security);
            bool hasFields          = fields != null && fields.Count != 0;
            bool hasOptions         = options != null && options.Count != 0;
            bool separatorsAppended = false;

            if (hasFields)
            {
                foreach (string current in fields)
                {
                    if (current != null && current.Length > 0)
                    {
                        if (!separatorsAppended)
                        {
                            stringBuilder.Append(TOPIC_OPTIONS_SEPARATOR);
                            stringBuilder.Append(FIELDS_OPTION);
                            separatorsAppended = true;
                        }
                        else
                        {
                            stringBuilder.Append(FIELDS_SEPARATOR);
                        }
                        stringBuilder.Append(current);
                    }
                }
            }
            if (hasOptions)
            {
                foreach (string current2 in options)
                {
                    if (current2 != null && current2.Length > 0)
                    {
                        if (!separatorsAppended)
                        {
                            stringBuilder.Append(TOPIC_OPTIONS_SEPARATOR);
                            separatorsAppended = true;
                        }
                        else
                        {
                            stringBuilder.Append(OPTIONS_SEPARATOR);
                        }
                        stringBuilder.Append(current2);
                    }
                }
            }
            this.d_subscriptionString = stringBuilder.ToString();
            this.d_correlationId      = correlationID;
            this._security            = Subscription.CheckSecurity(security);

            if (fields != null)
            {
                this._fields = new List <string>(fields.Select(s => Subscription.CheckField(s)));
            }

            if (options != null)
            {
                this._conflationInterval = this.ReadConflationInterval(options);
            }
        }
コード例 #8
0
ファイル: Subscription.cs プロジェクト: zeta1999/bemux
 public Subscription(string security, IList <string> fields, CorrelationID correlationID) : this(security, fields, null, correlationID)
 {
 }
コード例 #9
0
ファイル: Subscription.cs プロジェクト: zeta1999/bemux
 public Subscription(string security, string fields, CorrelationID correlationId) : this(security, fields, "", correlationId)
 {
 }
コード例 #10
0
ファイル: Subscription.cs プロジェクト: zeta1999/bemux
 public Subscription(string subscriptionString, CorrelationID correlationID) : this(subscriptionString, correlationID, false)
 {
 }
コード例 #11
0
ファイル: Subscription.cs プロジェクト: zeta1999/bemux
 internal Subscription(string subscriptionString, CorrelationID correlationID, Session.SubscriptionStatus status)
 {
     this.d_subscriptionString = subscriptionString;
     this.d_correlationId      = correlationID;
     this.d_subscriptionStatus = status;
 }
コード例 #12
0
ファイル: Session.cs プロジェクト: zeta1999/bemux
 public void Unsubscribe(CorrelationID correlationId)
 {
     this.Cancel(correlationId);
 }
コード例 #13
0
ファイル: Session.cs プロジェクト: zeta1999/bemux
 public void OpenServiceAsync(string uri, CorrelationID correlationId)
 {
     this._sessionUri           = SessionUriType.mktData;
     this._sessionState         = SessionStateType.serviceOpened;
     this._asyncOpenCorrelation = correlationId;
 }
コード例 #14
0
ファイル: Session.cs プロジェクト: zeta1999/bemux
 public CorrelationID SendRequest(Request request, EventQueue eventQueue, CorrelationID correlationId)
 {
     eventQueue.Session = this;
     return(this.SendRequest(request, correlationId));
 }
コード例 #15
0
 public CorrelationID(CorrelationID value)
 {
     this._corrType = value._corrType;
     this._value    = value._value;
     this._object   = value._object;
 }
コード例 #16
0
ファイル: Message.cs プロジェクト: vsujeesh/bemu
 protected Message(Name messageType, CorrelationID corr, Service service)
 {
     this._correlationId = corr;
     this._messageType   = messageType;
     this._service       = service;
 }