예제 #1
0
파일: FortsTrade.cs 프로젝트: Groxan/RepVol
        private int MessageHandlerAggr(Connection conn, Listener listener, Message msg)
        {
            try
            {
                if (msg.Type == MessageType.MsgData)              // DATA
                {
                    if ((msg as DataMessage).MsgName == "FORTS_MSG101")
                    {
                        SchemeFortsMsg.FORTS_MSG101 repl = new SchemeFortsMsg.FORTS_MSG101(msg.Data);
                        if (repl.code == 0)
                            Ticket = repl.order_id;
                        else
                        {
                            errMessage = repl.message;
                            Ticket = -repl.code;
                        }
                        Execution = false;
                    }
                    else if ((msg as DataMessage).MsgName == "FORTS_MSG102")
                    {
                        SchemeFortsMsg.FORTS_MSG102 repl = new SchemeFortsMsg.FORTS_MSG102(msg.Data);
                        if (repl.code == 0)
                            Ticket = repl.amount;
                        else
                        {
                            errMessage = repl.message;
                            Ticket = -repl.code;
                        }
                        Execution = false;
                    }
                    else if ((msg as DataMessage).MsgName == "FORTS_MSG103")
                    {
                        SchemeFortsMsg.FORTS_MSG103 repl = new SchemeFortsMsg.FORTS_MSG103(msg.Data);
                        if (repl.code == 0)
                            Ticket = repl.num_orders;
                        else
                        {
                            errMessage = repl.message;
                            Ticket = -repl.code;
                        }
                        Execution = false;
                    }
                    else if ((msg as DataMessage).MsgName == "FORTS_MSG105")
                    {
                        SchemeFortsMsg.FORTS_MSG105 repl = new SchemeFortsMsg.FORTS_MSG105(msg.Data);
                        if (repl.code == 0)
                            Ticket = repl.order_id1;
                        else
                        {
                            errMessage = repl.message;
                            Ticket = -repl.code;
                        }
                        Execution = false;
                    }
                    else if ((msg as DataMessage).MsgName == "FORTS_MSG99")
                    {
                        SchemeFortsMsg.FORTS_MSG99 repl = new SchemeFortsMsg.FORTS_MSG99(msg.Data);

                        Execution = false;
                    }
                    else if ((msg as DataMessage).MsgName == "FORTS_MSG100")
                    {
                        SchemeFortsMsg.FORTS_MSG100 repl = new SchemeFortsMsg.FORTS_MSG100(msg.Data);

                        Execution = false;
                    }
                }
                else if (msg.Type == MessageType.MsgP2MQTimeout)
                {
                    errMessage = "Таймаут";
                    Ticket = -1488;
                    Execution = false;
                }
                else if (msg.Type == MessageType.MsgOpen)               // OPEN
                {
                    if (listener.Scheme != null)
                    {
                        SchemeFortsMsg fM = new SchemeFortsMsg();
                        if (!fM.CheckScheme(GetShortSchemeString(listener.Scheme)))
                        {
                            Log(new MPlazaEvent(MPlazaEvents.SchemeChanged));
                        }
                    }
                }
                else if (msg.Type == MessageType.MsgP2ReplReplState)    // REPLSTATE
                {
                    lisPubReplState = ((P2ReplStateMessage)msg).ReplState.TrimEnd((char)0);
                }
                else
                {
                }
                return 0;
            }
            catch (CGateException err)
            {
                errMessage = err.Message;
                Log(new MPlazaEvent(MPlazaEvents.Error));
                Execution = false;
                return (int)err.ErrCode;
            }
        }
예제 #2
0
파일: MPDLL.cs 프로젝트: Groxan/RepVol
        private int MessageHandlerTrade(Connection conn, Listener listener, Message msg)
        {
            try
            {
                if (msg.Type == MessageType.MsgData)              // DATA
                {
                    if ((msg as DataMessage).MsgName == "FORTS_MSG101")
                    {
                        SchemeFortsMsg.FORTS_MSG101 repl = new SchemeFortsMsg.FORTS_MSG101(msg.Data);
                        if (repl.code == 0)
                            Ticket = repl.order_id;
                        else
                        {
                            errMessage = repl.message;
                            Ticket = -repl.code;
                        }
                        Execution = false;
                    }
                    else if ((msg as DataMessage).MsgName == "FORTS_MSG102")
                    {
                        SchemeFortsMsg.FORTS_MSG102 repl = new SchemeFortsMsg.FORTS_MSG102(msg.Data);
                        if (repl.code == 0)
                            Ticket = repl.amount;
                        else
                        {
                            errMessage = repl.message;
                            Ticket = -repl.code;
                        }
                        Execution = false;
                    }
                    else if ((msg as DataMessage).MsgName == "FORTS_MSG103")
                    {
                        SchemeFortsMsg.FORTS_MSG103 repl = new SchemeFortsMsg.FORTS_MSG103(msg.Data);
                        if (repl.code == 0)
                            Ticket = repl.num_orders;
                        else
                        {
                            errMessage = repl.message;
                            Ticket = -repl.code;
                        }
                        Execution = false;
                    }
                    else if ((msg as DataMessage).MsgName == "FORTS_MSG105")
                    {
                        SchemeFortsMsg.FORTS_MSG105 repl = new SchemeFortsMsg.FORTS_MSG105(msg.Data);
                        if (repl.code == 0)
                            Ticket = repl.order_id1;
                        else
                        {
                            errMessage = repl.message;
                            Ticket = -repl.code;
                        }
                        Execution = false;
                    }
                    else if ((msg as DataMessage).MsgName == "FORTS_MSG99")
                    {
                        SchemeFortsMsg.FORTS_MSG99 repl = new SchemeFortsMsg.FORTS_MSG99(msg.Data);
                        errMessage = repl.message;
                        OnError(new ErrorEvent("FORTS_MSG99: " + repl.message));
                        Execution = false;
                    }
                    else if ((msg as DataMessage).MsgName == "FORTS_MSG100")
                    {
                        SchemeFortsMsg.FORTS_MSG100 repl = new SchemeFortsMsg.FORTS_MSG100(msg.Data);
                        errMessage = repl.message;
                        OnError(new ErrorEvent("FORTS_MSG100: " + repl.message));
                        Execution = false;
                    }
                }
                else if (msg.Type == MessageType.MsgP2MQTimeout)
                {
                    errMessage = "Таймаут";
                    Ticket = -1488;
                    Execution = false;
                }
                else if (msg.Type == MessageType.MsgOpen)               // OPEN
                {
                    mtx.WaitOne();
                    FutTradeOnline = true;

                    if (FutInfoOnline && FutPartOnline && FutPosOnline && FutTradeOnline && FutVMOnline && FutCommonOnline && FutDealsOnline && FutDrinksOnline)
                        Status = MPlazaStatus.OK;

                    mtx.ReleaseMutex();
                }
                else if (msg.Type == MessageType.MsgP2ReplReplState)    // REPLSTATE
                {
                    lisPubReplState = ((P2ReplStateMessage)msg).ReplState.TrimEnd((char)0);
                }
                msg.Dispose();
                return 0;
            }
            catch (Exception err)
            {
                errMessage = err.Message;
                Status = MPlazaStatus.Error;
                OnError(new ErrorEvent(errMessage));
                msg.Dispose();
                return -1;
            }
        }