public virtual FIXTMessage1_1 Create() { var message = new FIXTMessage1_1(fixVersion, sender, destination); message.Sequence = GetNextSequence(); return(message); }
private void SendMessageInternal(FIXTMessage1_1 fixMsg) { var fixString = fixMsg.ToString(); if (debug) { string view = fixString.Replace(FIXTBuffer.EndFieldStr, " "); log.Debug("Send FIX message: \n" + view); } var packet = Socket.CreatePacket(); packet.DataOut.Write(fixString.ToCharArray()); var end = Factory.Parallel.TickCount + (long)heartbeatDelay * 1000L; while (!Socket.TrySendPacket(packet)) { if (IsInterrupted) { return; } if (Factory.Parallel.TickCount > end) { throw new ApplicationException("Timeout while sending heartbeat."); } Factory.Parallel.Yield(); } }
public void AddHistory(FIXTMessage1_1 fixMsg) { messageHistory.Add(fixMsg.Sequence, fixMsg); if (fixMsg.Sequence < FirstSequence) { firstSequence = fixMsg.Sequence; } lastSequence = fixMsg.Sequence; }
public virtual FIXTMessage1_1 Create(int previousSequence) { if (previousSequence > nextSequence) { throw new InvalidOperationException("Cannot create new fix message with sequence in the future."); } var message = new FIXTMessage1_1(fixVersion, sender, destination); message.Sequence = previousSequence; return(message); }
protected void ResendMessageProtected(FIXTMessage1_1 fixMessage) { if (isConnectionLost) { return; } var writePacket = fixSocket.MessageFactory.Create(); var message = fixMessage.ToString(); writePacket.DataOut.Write(message.ToCharArray()); writePacket.SendUtcTime = TimeStamp.UtcNow.Internal; if (debug) { log.Debug("Resending simulated FIX Message: " + fixMessage); } SendMessageInternal(writePacket); }
public bool TryGetHistory(int sequence, out FIXTMessage1_1 result) { return(messageHistory.TryGetValue(sequence, out result)); }
public void SendMessage(FIXTMessage1_1 fixMsg) { fixFactory.AddHistory(fixMsg); SendMessageInternal(fixMsg); }
public void SendMessage(FIXTMessage1_1 fixMessage) { FixFactory.AddHistory(fixMessage); if (isConnectionLost) { RemoveTickSync(fixMessage); return; } var simulator = simulators[SimulatorType.SendDisconnect]; if (simulator.CheckSequence(fixMessage.Sequence)) { if (debug) { log.Debug("Ignoring message: " + fixMessage); } ProviderSimulator.SwitchBrokerState("disconnect", false); isConnectionLost = true; return; } if (simulateSendFailed && IsRecovered && random.Next(50) == 4) { if (debug) { log.Debug("Skipping send of sequence # " + fixMessage.Sequence + " to simulate lost message. " + fixMessage); } if (fixMessage.Type == "1") { isHeartbeatPending = TimeStamp.MaxValue; } if (debug) { log.Debug("Message type is: " + fixMessage.Type); } return; } var writePacket = fixSocket.MessageFactory.Create(); var message = fixMessage.ToString(); writePacket.DataOut.Write(message.ToCharArray()); writePacket.SendUtcTime = TimeStamp.UtcNow.Internal; if (debug) { log.Debug("Simulating FIX Message: " + fixMessage); } try { fixPacketQueue.Enqueue(writePacket, writePacket.SendUtcTime); } catch (QueueException ex) { if (ex.EntryType == EventType.Terminate) { log.Warn("fix packet queue returned queue exception " + ex.EntryType + ". Dropping message due to dispose."); Dispose(); } else { throw; } } simulator = simulators[SimulatorType.SendServerOffline]; if (IsRecovered && FixFactory != null && simulator.CheckSequence(fixMessage.Sequence)) { if (debug) { log.Debug("Skipping message: " + fixMessage); } ProviderSimulator.SwitchBrokerState("offline", false); ProviderSimulator.SetOrderServerOffline(); if (requestSessionStatus) { SendSessionStatus("3"); } else { log.Info("RequestSessionStatus is false so not sending order server offline message."); } } }
protected abstract void RemoveTickSync(FIXTMessage1_1 textMessage);
protected abstract void ResendMessage(FIXTMessage1_1 textMessage);
public void AddHistory(FIXTMessage1_1 fixMsg) { messageHistory.Add(fixMsg.Sequence, fixMsg); lastSequence = fixMsg.Sequence; }