First of all, I'm new to SignalR so please bear with me here.
I'm currently interfacing to a Siemens Desigo CC WSI (Web Service Interface) which support subscriptions using SignalR.
I have made mock-up C# wrapper which has been imported to Delphi (TLB) and I can make this work, however I cannot figure out how to transfer that to "setup" to a TScHubConnection.
single hub: norisHub
Subscription to: eventCountersHub
C# code (snips)
Code: Select all
public interface IWSIEventSubscriberEvents
{
[DispId(1)]
void OnWSIEventCountersEvent(string eventText);
}
void FireCOMEventCountersEvent(string data)
{
OnWSIEventCountersEvent(data);
}
private IHubProxy HubEventCountersProxy { get; set; }
public string ConnectWSI()
{
mainDispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher;
System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, ClientCertificateOption, chain, sslPolicyErrors) => true);
Connection = new HubConnection(_ServerURI);
Connection.Closed += Connection_Closed;
// Connects to eventCounters subscription hub.
HubEventCountersProxy = Connection.CreateHubProxy("norisHub");
HubEventCountersProxy.On("notifyEventCounters", (data) =>
{
// Sends event to COM listener. in variable "data" we expects json string.
// This event will be handled in Delphi desigo app.
//
var jsonStr = new string[1];
jsonStr[0] = Convert.ToString(data);
mainDispatcher.Invoke(new MethodToInvokeDelegate(FireCOMEventCountersEvent), jsonStr);
}
);
In Delphi I have tried this.
Code: Select all
procedure TfrmMain.btnSubscribeSBClick(Sender: TObject);
var
json: String;
r : string;
url : string;
begin
url := 'https://'+edServerAddress.Text + '/norisHub'; //Same as in the wrapper
SignalRClient.Url := url;
SignalRClient.HttpConnectionOptions.Url := SignalRClient.Url; // in the demo URL's are identical
SignalRClient.Register('notifyEventCounters', DoEventCountersReceipt, [varString]);
SignalRClient.Start;
{
r := format('/sr/eventcounterssubscriptions/channelize/%s/%s',[FRequestId, FConnectionId]);
json := GetData(r, json);
}
end;