// the following method is passed to the MT4Man Wrapper // and serves as an async callback. // problem being the instance of wrapper manager either // myOutsideManager or myManager are set to null // when the asynch call chain gets here? protected static void CallBackMethod(int code) { // consider adding a collection of some kind queue, stack, etc // and put messages types on the queue // then have a registered event that processes // the queue when a message has arrived // or more brute forcish have a loop that processes // keystrokes, etc then allocate part of the cycle to proces // the que. String ErrorMessage = "Call back static callback"; // note Access to class attributes works // within the async call back miktek 8.09.12 int iRet = 0; // access to a global instance for counting miktekCSConAppTestHarness.globalTotal++; switch (code) { case PUMP_START_PUMPING: ErrorMessage = "PUMP_START_PUMPING"; break; case PUMP_UPDATE_GROUPS: ErrorMessage = "PUMP_UPDATE_GROUPS"; break; case PUMP_UPDATE_USERS: ErrorMessage = "PUMP_UPDATE_USERS"; UserRecordNET user = new UserRecordNET(); iRet = myManager.UserRecordGet(10021, user); break; case PUMP_UPDATE_ONLINE: ErrorMessage = "PUMP_UPDATE_ONLINE"; break; case PUMP_UPDATE_SYMBOLS: // 1 ErrorMessage = "PUMP_UPDATE_SYMBOLS"; break; case PUMP_STOP_PUMPING: // 14 ErrorMessage = "PUMP_STOP_PUMPING"; iRet = myManager.dummyFunction(14); break; case PUMP_UPDATE_TRADES: // 9 ErrorMessage = "PUMP_UPDATE_TRADES"; // this version is working as of 8.26.2012 // int intTotal = 0; ExposureValueNET[] ExposedArray; ExposedArray = myManager.ExposureGet(ref intTotal); TradeRecordNET[] TradeInfo; int val = 0; TradeInfo = myManager.TradesGet(ref val); MarginLevelNET margin = new MarginLevelNET(); iRet = myManager.MarginLevelGet(10021, "FQ-MM", margin); MarginLevelNET[] mrgnLevelNET; int marginTotal = 0; mrgnLevelNET = myManager.MarginsGet(ref marginTotal); break; case PUMP_UPDATE_BIDASK: ErrorMessage = "PUMP_UPDATE_BIDASK"; int iRecCount = 0; ExposureValueNET[] ExposedArray2; ExposedArray2 = myManager.ExposureGet(ref iRecCount); TickInfoNET[] TickInfoArray; int totalTicks = 0; TickInfoArray = myManager.TickInfoLast("AUDCAD", ref totalTicks); for (int i = 0; i < totalTicks; i++) { Console.WriteLine("TickInfo[" + i + "]: " + TickInfoArray[i].ask + " , " + TickInfoArray[i].bid); } break; case PUMP_PING: // 8.26.2012 ErrorMessage = "PUMP_PING AND PINGING BACK"; iRet = myManager.Ping(); break; case PUMP_UPDATE_MARGINCALL: ErrorMessage = "PUMP_UPDATE_MARGINCALL"; margin = new MarginLevelNET(); iRet = myManager.MarginLevelGet(10021, "FQ-MM", margin); marginTotal = 0; mrgnLevelNET = myManager.MarginsGet(ref marginTotal); break; case TEST_LOCAL: iRet = myManager.dummyFunction(34); ErrorMessage = "THIS IS A TEST 777"; break; default: ErrorMessage = "UNKNOWN"; code = 911; break; } Console.WriteLine("MSG: {0}, CODE: {1} TOTAL MSGS: {2}", ErrorMessage, code, miktekCSConAppTestHarness.globalTotal); }
// log notes: // Editing codebase to allow calls passing and receiving structures // miktek 8.15.2011 /* * This function is passed as a delegate function for PumpingSwitchEx. * Parameters of CallBackMethodEx, * code: type of change. * type: type of transaction such as TRANS_ADD, TRANS_DELETE etc. * data: pointer to updated data, type of this pointer depends on the type of change i.e. if we get PUMP_UPDATE_TRADES code, void pointer data points to TradeRecord structure. There are about 8 code data pointer types, for detail see MT4 Manager API document. * param: pointer that has been passed as a parameter to the PumpingSwitchEx function. * */ protected static void CallBackMethodEx(int code, int type, Object data, Object param) { String ErrorMessage = "Call back static callback"; int iRet = 0; //Here code data pointer type relationship is like as follows, //PUMP_UPDATE_USERS - UserRecord structure //PUMP_UPDATE_ONLINE - client's login in the int form //PUMP_UPDATE_TRADES - TradeRecord structure //For now, we have used these data values UserRecordNET, client's login and TradeRecordNET. //If 'data' is other than these types, it will have null value. //For more code data relationship, refer "MT4 Manager API Documentation.pdf". if (data != null) { Console.WriteLine("Type of Data: " + data.GetType().ToString()); } // access to a global instance for counting miktekCSConAppTestHarness.globalTotal++; switch (code) { case PUMP_START_PUMPING: ErrorMessage = "PUMP_START_PUMPING"; break; case PUMP_UPDATE_USERS: ErrorMessage = "PUMP_UPDATE_USERS"; UserRecordNET user = new UserRecordNET(); int i = myManager.UserRecordGet(10020, user); if (data != null) { UserRecordNET userInfo = (UserRecordNET)data; Console.WriteLine("User's login: "******"PUMP_UPDATE_ONLINE"; if (data != null) { int login = (int)data; Console.WriteLine("User's Login: "******"PUMP_STOP_PUMPING"; iRet = myManager.dummyFunction(14); break; case PUMP_UPDATE_TRADES: // 9 ErrorMessage = "PUMP_UPDATE_TRADES"; // this version is working as of 8.26.2012 // int intTotal = 0; ExposureValueNET[] ExposedArray; ExposedArray = myManager.ExposureGet(ref intTotal); int marginTotal = 0; MarginLevelNET[] mrgnLevelNET; mrgnLevelNET = myManager.MarginsGet(ref marginTotal); MarginLevelNET margin = new MarginLevelNET(); iRet = myManager.MarginLevelGet(10021, "FQ-MM", margin); int value = 0; TradeRecordNET[] TradeInfo; TradeInfo = myManager.TradesGet(ref value); if (data != null) { TradeRecordNET trade = (TradeRecordNET)data; Console.WriteLine("Trade Order: " + trade.order); } break; case PUMP_PING: // 8.26.2012 ErrorMessage = "PUMP_PING AND PINGING BACK"; iRet = myManager.Ping(); break; default: ErrorMessage = "UNKNOWN"; code = 911; break; } Console.WriteLine("MSG: {0}, CODE: {1} TOTAL MSGS: {2}", ErrorMessage, code, miktekCSConAppTestHarness.globalTotal); }