C# | Visual Basic | Visual C++ |
void Publish( ICommandListener listener, string subject, IPublishParameters parameters )
Sub Publish ( _ listener As ICommandListener, _ subject As String, _ parameters As IPublishParameters _ )
void Publish( ICommandListener^ listener, String^ subject, IPublishParameters^ parameters )
- listener (ICommandListener)
- The listener that will receive the results of the publish command.
- subject (String)
- The name of the subject to publish to (update).
- parameters (IPublishParameters)
- The parameters of the publish command.
An API client can publish updates to any subject to which it has write access, regardless of whether the object was created by itself, by another StreamLink client, or by one of the server's DataSources. If the object was created by a DataSource then the values will be passed on to that DataSource for processing.
At present the Liberator will only accept updates to subjects of type Record.
Note: If an application publishes values for fields that are not configured on the server, the publication command will appear to succeed; however values for any fields that are not configured will be ignored. For example if a client publishes values for the fields Bid and BidSize to a server that doesn't have the BidSize field configured, only the Bid value will be updated.
using System; using System.Collections.Generic; using System.Text; using Caplin.StreamLink; using Caplin.StreamLink.Authentication; using Caplin.StreamLink.Command; namespace StreamLinkExamples.Commands { public class PublishToSubject { /// <summary> /// Example of how to create a new Record subject on the Liberator. /// </summary> public static void PublishToASubjectExample() { StreamLink myStreamLink = new StreamLink(); myStreamLink.CredentialsProvider = new PasswordCredentialsProvider("admin", "admin"); myStreamLink.StreamLinkProvider.Connect(); // Identify the fields to be published to and the values to be published. Dictionary<string,string> fieldsAndValues = new Dictionary<string,string>(); fieldsAndValues.Add("Bid", "200"); fieldsAndValues.Add("Volume", "10000"); // Create the publish parameters using the fields and their values. IPublishParameters publishParameters = myStreamLink.StreamLinkProvider.ParametersFactory.CreatePublishParameters(fieldsAndValues); // listener called when the command has finished executing ICommandListener listener = new ExampleCommandListener(); // Submit the publish command myStreamLink.StreamLinkProvider.Publish(listener, "Subject", publishParameters); } } }