Infront Data Manager Connect Client (.NET)

Create Push Client

A Push Client is the central point where updates are delivered.

To create your onw class(required) follow these steps:

1. Derive your own class from PushClient (Gevasys.DataCore.Client.PushClient )
2. Override the ProcessUpdates method with your custom implementation to process incoming updates (Gevasys.DataCore.Client.PushClient.ProcessUpdates)
3. Override the Update method with your custom implementation to process incoming status messages for the consumer.

Note: Push Client Sample is provided as well in the Data Manager Connect Distributions for Java and .NET. Available online for the closed user group at https://www.vwd.com/ .

using System;
using System.Collections.Generic;
using Gevasys.DataCore.Client;
using Gevasys.DataCore.Core;
using Gevasys.DataCore.Core.Protocol;
using Gevasys.DataCore.Core.Protocol.Binary;
using Gevasys.DataCore.Core.Protocol.Binary.Decoding;
using Gevasys.DataCore.RequestData.ProtoBuf.V2;
using Gevasys.DataCore.Tools.Protocol;
namespace Examples
{
class SamplePushClient : PushClient
{
public SamplePushClient(string name) : base(name)
{
}
public override void ProcessUpdates(List<Gevasys.DataCore.Core.Protocol.UpdateMessage> updates)
{
foreach (UpdateMessage update in updates)
{
switch (update.MessageType)
{
case BaseBinaryMessage.MessageType.Proto:
//Get the Message ID
StringField sf = (StringField)update.GetField(1);
//News
if (sf.Value.Equals(MessageIdentifier.NewsMessage))
{
NewsListEntryMessage nm = ProtobufMessageHelper.deserializeNewsMessage(update);
}
break;
case BaseBinaryMessage.MessageType.PartialRecap:
case BaseBinaryMessage.MessageType.Recap:
case BaseBinaryMessage.MessageType.Update:
ProcessUpdateOrRecap(update);
break;
case BaseBinaryMessage.MessageType.RequestStatus:
if (((RequestStatusMessage)update).Status == RequestStatusType.NotDefined)
{
Console.WriteLine("Instrument not definied: " + update.GetInstrument());
}
else if (((RequestStatusMessage)update).Status == RequestStatusType.NoPermission)
{
Console.WriteLine("No permission for instrument: " + update.GetInstrument());
}
else if (((RequestStatusMessage)update).Status == RequestStatusType.NotFound)
{
Console.WriteLine("Instrument not found: " + update.GetInstrument());
}
else if (((RequestStatusMessage)update).Status == RequestStatusType.ServiceNotAvailable)
{
Console.WriteLine("Underlying data service is not available");
}
break;
default:
break;
}
//Attention! Possible heavy CPU usage due console output.
Console.WriteLine(update.toMachineReadableOutput());
}
}
private void ProcessUpdateOrRecap(UpdateMessage update)
{
//Iterate through all field of update
foreach (BaseField field in update.FieldDict.Values)
{
ProcessFieldUpdate(field);
}
//And/or
//Direct access to fields (see vwdFieldmap.xml)
BaseField outField = null;
if (update.TryGetField(80, out outField))
{
ProcessFieldUpdate(outField);
}
}
private void ProcessFieldUpdate(BaseField field)
{
short fieldId = field.FieldId;
switch (field.DataTypeValue)
{
case BaseBinaryMessage.DataType.String:
string stringValue = ((StringField)field).Value;
break;
case BaseBinaryMessage.DataType.DateTime:
DateTime timeValue = ((DateTimeField)field).Value;
break;
case BaseBinaryMessage.DataType.Double:
double doubleValue = ((DoubleField)field).Value;
break;
case BaseBinaryMessage.DataType.Float:
float floatValue = ((FloatField)field).Value;
break;
case BaseBinaryMessage.DataType.Int32:
int intValue = ((IntField)field).Value;
break;
case BaseBinaryMessage.DataType.Long:
long longValue = ((LongField)field).Value;
break;
case BaseBinaryMessage.DataType.Short:
short shortField = ((ShortField)field).Value;
break;
}
}
public override void Update(IConsumer source, ConsumerStateChangedEventArgs arg)
{
if (arg.IsOnline)
{
//Consumer is online. Feed data will be received.
}
else
{
//Consumer is offline. No feed data will be received.
}
}
}
}
Gevasys.DataCore
Definition: BinaryUpstreamClient.cs:5
Gevasys.DataCore.Tools
Definition: FieldData.cs:4
Gevasys.DataCore.Client.PushClient.Update
abstract void Update(DataCore.Core.IConsumer source, ConsumerStateChangedEventArgs arg)
Abstract method that must be implemented in derived classes to recive status notifications for the un...
Gevasys.DataCore.Client.PushClient.ProcessUpdates
abstract void ProcessUpdates(List< UpdateMessage > updates)
Gevasys.DataCore.Client
Definition: BinaryUpstreamClient.cs:5
Gevasys.DataCore.Core.Protocol
Definition: RequestStatusMessage.cs:8
Gevasys
Definition: BinaryUpstreamClient.cs:5
Gevasys.DataCore.Core
Definition: CompressionHelper.cs:7
Examples
Definition: apiinitialize.cs:11
Gevasys.DataCore.Tools.Protocol
Definition: ProtobufMessageHelper.cs:7

Copyright (C) 2021 Infront Financial Technology GmbH
Mainzer Landstrasse 178 – 190
60327 Frankfurt am Main
Infront Data Manager Connect V4.1