/// <summary> /// Gets a user-friendly string for Broker and TradeLink error messages. /// </summary> /// <param name="errorcode">The errorcode.</param> /// <returns></returns> public static string PrettyError(Brokers broker, int errorcode) { TL2 message = (TL2)errorcode; switch (message) { // tradelink messages case TL2.FEATURE_NOT_IMPLEMENTED: return("Feature not implemented yet."); case TL2.UNKNOWNSYM: return("Unknown symbol."); case TL2.UNKNOWNMSG: return("Unknown message."); case TL2.TL_CONNECTOR_MISSING: return("TradeLink Server not found."); case TL2.GOTNULLORDER: return("Unable to read order."); case TL2.OK: return("Ok"); default: // broker-specific messages if (broker == Brokers.Assent) { return(Enum.GetName(typeof(AnvilSendOrderError), errorcode)); } if (broker == Brokers.Echo) { return(Enum.GetName(typeof(SterlingSubmitOrderError), errorcode)); } break; } return("Unknown error: " + errorcode.ToString()); }
protected long TLSend(TL2 type, string m) { if (himh == IntPtr.Zero) { throw new TLServerNotFound(); } long res = WMUtil.SendMsg(m, himh, Handle, (int)type); return(res); }
protected long TLSend(TL2 type, string m) { if (himh == IntPtr.Zero) throw new TLServerNotFound(); long res = WMUtil.SendMsg(m, himh, Handle, (int)type); return res; }
protected long TLSend(TL2 type) { return TLSend(type, ""); }
/// <summary> /// Sends the MSG from source window to destination window, using WM_COPYDATA. /// </summary> /// <param name="message">The message.</param> /// <param name="messagetype">The messagetype.</param> /// <param name="destinationwindow">The destinationwindow.</param> /// <returns></returns> public static long SendMsg(string message, TL2 messagetype, IntPtr sourcehandle, string destinationwindow) { IntPtr him = WMUtil.HisHandle(destinationwindow); return(WMUtil.SendMsg(message, him, sourcehandle, (int)messagetype)); }
public LinkMessage(TL2 t) { Type = t; }
public LinkMessage(TL2 t, object m) { Type = t; Body = m; }
void TLSend(TL2 type) { TLSend(Him, new LinkMessage(type)); }
void gotMessage(object sender, ReceiveCompletedEventArgs e) { TL2 mt = TL2.INFO; string from = ""; LinkMessage gotmess = null; object m = null; gotmess = (LinkMessage)e.Message.Body; mt = gotmess.Type; m = gotmess.Body; from = gotmess.From; int cid = -1; Tick t = new Tick(); try { switch (mt) { // CLIENT MESSAGES case TL2.TICKNOTIFY: t = (Tick)m; gotTick(t); break; case TL2.EXECUTENOTIFY: Trade trade; trade = (Trade)m; gotFill(trade); break; // SERVER MESSAGES case TL2.REGISTERCLIENT: if (client.IndexOf(from) != -1) { break; // we already had your client, ignore } client.Add(from); stocks.Add(""); heart.Add(new DateTime()); break; case TL2.REGISTERSTOCK: cid = client.IndexOf(from); if (cid == -1) { break; // client not found } MarketBasket mb = (MarketBasket)m; stocks[cid] = mb.ToString(); BeatHeart(from); break; case TL2.HEARTBEAT: BeatHeart(from); break; case TL2.CLEARSTOCKS: cid = client.IndexOf(from); if (cid == -1) { break; } stocks[cid] = null; BeatHeart(from); break; case TL2.CLEARCLIENT: cid = client.IndexOf(from); if (cid == -1) { break; // we don't have the client, nothing to do } client[cid] = null; stocks[cid] = null; heart[cid] = new DateTime(); break; } } catch (Exception ex) { string s = ex.Message; } if (this.GotMessage != null) { GotMessage(mt, from); // send GotMessage event to any subscribers } rec.BeginReceive(); // prepare to receive new messages }
/// <summary> /// Sends the MSG from source window to destination window, using WM_COPYDATA. /// </summary> /// <param name="message">The message.</param> /// <param name="messagetype">The messagetype.</param> /// <param name="destinationwindow">The destinationwindow.</param> /// <returns></returns> public static long SendMsg(string message, TL2 messagetype, IntPtr sourcehandle,string destinationwindow) { IntPtr him = WMUtil.HisHandle(destinationwindow); return WMUtil.SendMsg(message, him,sourcehandle, (int)messagetype); }
protected long TLSend(TL2 type) { return(TLSend(type, "")); }