//IntPtr conn; public CP2ConnectorNative(IAlarmable alarmer) { dtStarted = DateTime.Now; _alarmer = alarmer; //_alarmer.Error("Test"); _log = new CLogger("NatConnectionMarket"); _log.Log("+++++++++++++++++++++++++++++++++ Connection started +++++++++++++++++++++++++++++++++++++++++++++++"); CallbackDelegate = Callback; UInt32 res = cg_env_open("ini=repl.ini;key=11111111"); unsafe { int *conn = null; res = cg_conn_new("p2tcp://127.0.0.1:4001;app_name=test_nat", &conn); protConn = (IntPtr)conn; int * lstn = null; void *data = null; //res = cg_lsn_new(conn, "p2repl://FORTS_DEALS_REPL;tables=deal", CallbackDelegate, data, &lstn); res = cg_lsn_new(conn, "p2repl://FORTS_FUTAGGR50_REPL", CallbackDelegate, data, &lstn); UInt32 state; bool bExit = false; while (!bExit) { res = cg_conn_getstate(conn, &state); if (state == CG_STATE_ERROR) { res = cg_conn_close(conn); } else if (state == CG_STATE_CLOSED) { res = cg_conn_open(conn, ""); } else if (state == CG_STATE_ACTIVE) { res = cg_conn_process(conn, 0, null); res = cg_lsn_getstate(lstn, &state); if (state == CG_STATE_CLOSED) { // res = cg_lsn_open(lstn, "mode=online"); res = cg_lsn_open(lstn, ""); } else if (state == CG_STATE_ERROR) { cg_lsn_close(lstn); } } } } // res = cg_conn_new("p2tcp://127.0.0.1:4001;app_name=test_repl", pt); }
public unsafe static extern UInt32 cg_lsn_new(void *conn, string settinf, CG_LISTENER_CB cb, void *data, int **lsnptr);