void TLSend(string to, LinkMessage m) { Outbound = to; if (!hasQueueEnds) { return; } m.From = Me; System.Messaging.Message sm = new System.Messaging.Message(m); sm.ResponseQueue = rec; sm.Formatter = new BinaryMessageFormatter(); xmt.Send(sm); }
void TLSend(string to, LinkMessage m) { Outbound = to; if (!hasQueueEnds) return; m.From = Me; System.Messaging.Message sm = new System.Messaging.Message(m); sm.ResponseQueue = rec; sm.Formatter = new BinaryMessageFormatter(); xmt.Send(sm); }
void TLSend(LinkMessage m) { TLSend(Him, m); }
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 }