static void settable_SendMessageEvent(MessageTypes type, long source, long dest, long msgid, string request, ref string response) { switch (type) { case MessageTypes.SENDUSERSETTABLE: tmp_settablelist = request; break; case MessageTypes.BARREQUEST: { var br = BarRequest.Deserialize(request); if (br.isValid) { br.symbol = string.Empty; bool addit = true; for (int i = 0; i < tmp_barreqs.Count; i++) { var cmp = tmp_barreqs[i]; if ((cmp.CustomInterval == br.CustomInterval) && (cmp.Interval == br.Interval) && (cmp.BarsBackExplicit == br.BarsBackExplicit)) { addit = false; break; } } if (addit) { tmp_barreqs.Add(br); } } } break; } }
public virtual bool SendMessage(MessageTypes type, long source, long dest, long msgid, string request, string response) { if (_tl == null) { return(false); } if (!_tl.RequestFeatureList.Contains(type)) { SendDebug(type.ToString() + " not supported by " + _tl.Name); return(false); } try { // prepare message switch (type) { case MessageTypes.DOMREQUEST: request = request.Replace(Book.EMPTYREQUESTOR, _tl.Name); break; case MessageTypes.BARREQUEST: { BarRequest br = BarRequest.Deserialize(request); br.Client = _tl.Name; request = BarRequest.Serialize(br); } break; case MessageTypes.FEATUREREQUEST: request = _tl.Name; break; case MessageTypes.IMBALANCEREQUEST: request = _tl.Name; break; } // send it long result = _tl.TLSend(type, request); string res = result.ToString(); // pass along result if ((SendMessageResponse != null) && (result != 0)) { SendMessageResponse(type, source, dest, msgid, request, ref res); } return(true); } catch (Exception ex) { debug("Error on: " + type.ToString() + source + dest + msgid + request + response); debug(ex.Message + ex.StackTrace); } return(false); }
/// <summary> /// send a message to providers /// </summary> /// <param name="type"></param> /// <param name="source"></param> /// <param name="dest"></param> /// <param name="msgid"></param> /// <param name="message"></param> /// <param name="result"></param> /// <returns></returns> public long TLSend(MessageTypes type, long source, long dest, long msgid, string message, ref string result) { v(type.ToString() + " sending to all providers: " + message); for (int i = 0; i < _pcon.Count; i++) { if (_pcon[i].RequestFeatureList.Contains(type)) { // prepare message switch (type) { case MessageTypes.DOMREQUEST: message = message.Replace(Book.EMPTYREQUESTOR, _pcon[i].Name); break; case MessageTypes.BARREQUEST: { BarRequest br = BarRequest.Deserialize(message); br.Client = _pcon[i].Name; message = BarRequest.Serialize(br); } break; case MessageTypes.FEATUREREQUEST: message = _pcon[i].Name; break; } long res = _pcon[i].TLSend(type, message); result = res.ToString(); if (gotUnknownMessage != null) { gotUnknownMessage(type, source, dest, msgid, message, ref result); } return(res); } else if (VerboseDebugging) { v(_pcon[i].BrokerName + " " + _pcon[i].Name + " does not support feature " + type + ", dropping message."); } } return(0); }