事件
我們使用solace作為mesh broker。事件可視為你與solace的連接狀態。如果你沒有相關網路經驗,可以略過此部分。不用擔心在不用任何的設定下,我們將重連預設為50次。只需要請你確保你的網絡連接狀態正常。
設定事件callback,如同報價callback的設定方式。
In
public class Program
{
private static void myEB(int respCode, int eventCode, string eventInfo, string eventStatus)
{
Console.WriteLine($"myEB -Response Code: {respCode} | Event code: {eventCode} | Info: {eventInfo} | Event: {eventStatus}");
}
private static void myQuoteCB_v1(Exchange exchange, dynamic quote)
{
Console.WriteLine($"QuoteCB_v1 | Exchange.{exchange} {quote.GetType().Name} {quote}");
}
public static void Main(string[] args)
{
var _api = new Shioaji();
// version >= 1.0
var _accounts = _api.Login("YOUR_API_KEY", "YOUR_SECRET_KEY");
// version <1.0
// var _accounts = _api.Login("PERSON_ID", "PASSWORD");
_api.SetQuoteCallback_v1(myQuoteCB_v1);
_api.SetEventCallback(myEB);
_api.Subscribe(
_api.Contracts.Futures["TXF"]["TXF202304"],
QuoteType.bidask,
version:QuoteVersion.v1
);
}
}
Out
myEB -Response Code: 0 | Event code: 16 | Info: QUO/v1/FOP/ */TFE/TXFD3 | Event: SubscriptionOk
事件代碼¶
Event Code | Event Code Enumerator | Description |
---|---|---|
0 | SOLCLIENT_SESSION_EVENT_UP_NOTICE | The Session is established. |
1 | SOLCLIENT_SESSION_EVENT_DOWN_ERROR | The Session was established and then went down. |
2 | SOLCLIENT_SESSION_EVENT_CONNECT_FAILED_ERROR | The Session attempted to connect but was unsuccessful. |
3 | SOLCLIENT_SESSION_EVENT_REJECTED_MSG_ERROR | The appliance rejected a published message. |
4 | SOLCLIENT_SESSION_EVENT_SUBSCRIPTION_ERROR | The appliance rejected a subscription (add or remove). |
5 | SOLCLIENT_SESSION_EVENT_RX_MSG_TOO_BIG_ERROR | The API discarded a received message that exceeded the Session buffer size. |
6 | SOLCLIENT_SESSION_EVENT_ACKNOWLEDGEMENT | The oldest transmitted Persistent/Non-Persistent message that has been acknowledged. |
7 | SOLCLIENT_SESSION_EVENT_ASSURED_PUBLISHING_UP | Deprecated -- see notes in solClient_session_startAssuredPublishing.The AD Handshake (that is, Guaranteed Delivery handshake) has completed for the publisher and Guaranteed messages can be sent. |
8 | SOLCLIENT_SESSION_EVENT_ASSURED_CONNECT_FAILED | Deprecated -- see notes in solClient_session_startAssuredPublishing.The appliance rejected the AD Handshake to start Guaranteed publishing. Use SOLCLIENT_SESSION_EVENT_ASSURED_DELIVERY_DOWN instead. |
8 | SOLCLIENT_SESSION_EVENT_ASSURED_DELIVERY_DOWN | Guaranteed Delivery publishing is not available.The guaranteed delivery capability on the session has been disabled by some action on the appliance. |
9 | SOLCLIENT_SESSION_EVENT_TE_UNSUBSCRIBE_ERROR | The Topic Endpoint unsubscribe command failed. |
9 | SOLCLIENT_SESSION_EVENT_DTE_UNSUBSCRIBE_ERROR | Deprecated name; SOLCLIENT_SESSION_EVENT_TE_UNSUBSCRIBE_ERROR is preferred. |
10 | SOLCLIENT_SESSION_EVENT_TE_UNSUBSCRIBE_OK | The Topic Endpoint unsubscribe completed. |
10 | SOLCLIENT_SESSION_EVENT_DTE_UNSUBSCRIBE_OK | Deprecated name; SOLCLIENT_SESSION_EVENT_TE_UNSUBSCRIBE_OK is preferred. |
11 | SOLCLIENT_SESSION_EVENT_CAN_SEND | The send is no longer blocked. |
12 | SOLCLIENT_SESSION_EVENT_RECONNECTING_NOTICE | The Session has gone down, and an automatic reconnect attempt is in progress. |
13 | SOLCLIENT_SESSION_EVENT_RECONNECTED_NOTICE | The automatic reconnect of the Session was successful, and the Session was established again. |
14 | SOLCLIENT_SESSION_EVENT_PROVISION_ERROR | The endpoint create/delete command failed. |
15 | SOLCLIENT_SESSION_EVENT_PROVISION_OK | The endpoint create/delete command completed. |
16 | SOLCLIENT_SESSION_EVENT_SUBSCRIPTION_OK | The subscribe or unsubscribe operation has succeeded. |
17 | SOLCLIENT_SESSION_EVENT_VIRTUAL_ROUTER_NAME_CHANGED | The appliance's Virtual Router Name changed during a reconnect operation.This could render existing queues or temporary topics invalid. |
18 | SOLCLIENT_SESSION_EVENT_MODIFYPROP_OK | The session property modification completed. |
19 | SOLCLIENT_SESSION_EVENT_MODIFYPROP_FAIL | The session property modification failed. |
20 | SOLCLIENT_SESSION_EVENT_REPUBLISH_UNACKED_MESSAGES | After successfully reconnecting a disconnected session, the SDK received an unknown publisher flow name response when reconnecting the GD publisher flow. |