...
- an event of successful session establishment is handled with Business rules,
- then the required message is generated with scripts,
- lastly, the message is sent to the session.
...
News (MsgType = B) message is generated with parseMessage(<msg>) function and sent to every session with an 'Established' state.
...
Code Block | ||||
---|---|---|---|---|
| ||||
// Send News (35=B) Message to established session.
message="8=FIX.4.49=12335=B49=FIXCLIENT56=FIXEDGE34=252=20170518-08:52:04.492148=Welcome to TEST Server.10=213"; // The message should be with SOH symbols, find it attached below
status = getStringField(147); // Get information about session event.
//147=[xxxx] (Sender):(Target) (state)
var regexp = /.*\s+([\w-]+):([\w-]+)\s+(.*)/g;
match = regexp.exec(status);
if (match != null)
{
target = match[1];
sender = match[2];
state = match[3];
print("processEstablishedSession.js session '"+sender+"'-'"+target+"' state='"+state+"'.") //for debuging
if (state == 'Established')
{
// Create News message
parseMessage(message);
// Example of message fields update
setNumField(33, 2); // Update two line of text in group 33.
group = getGroup(33);
setStringField(group, 0, 58, "Welcome " + sender + "!");
time = getCurrentDate(DATETIMEUtc);
setStringField(group, 1, 58, "Connection time: " + dateToString(time));
// Send message back to Established session
send(target, sender); // Swap sender and target before sending back
}
} |
...
Market Data Request (MsgType = V) message is generated with transform(<targetprotocol>,<targetmessagetype>) function and sent only to a specific session with an 'Established' state.
...