示例#1
0
        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
        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
        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
 public Subscription(string security, IList <string> fields, CorrelationID correlationID) : this(security, fields, null, correlationID)
 {
 }
示例#9
0
 public Subscription(string security, string fields, CorrelationID correlationId) : this(security, fields, "", correlationId)
 {
 }
示例#10
0
 public Subscription(string subscriptionString, CorrelationID correlationID) : this(subscriptionString, correlationID, false)
 {
 }
示例#11
0
 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;
 }