Example #1
0
 static void OnStatus(object sender, SessionStatusEventArgs args)
 {
     Console.WriteLine("Status: {0}", args.Name);
     if (args.Name == "disconnected")
     {
         mExit = true;
     }
     mConnected = args.Connected;
 }
        void IO2GSessionStatus.onSessionStatusChanged(O2GSessionStatusCode status)
        {
            bool   connected;
            string name;

            switch (status)
            {
            case O2GSessionStatusCode.Connected:
                connected      = true;
                mTimeConverter = mSession.getTimeConverter();
                O2GLoginRules rules = mSession.getLoginRules();
                if (rules.isTableLoadedByDefault(O2GTableType.Offers))
                {
                    O2GResponse offers = rules.getTableRefreshResponse(O2GTableType.Offers);
                    ReadOffers(offers);
                    mReady = true;
                }
                else
                {
                    O2GRequestFactory reqFactory = mSession.getRequestFactory();
                    O2GRequest        request    = reqFactory.createRefreshTableRequest(O2GTableType.Offers);
                    mSession.sendRequest(request);
                    mReady = false;
                }
                name = "connected";
                break;

            case O2GSessionStatusCode.Connecting:
                connected = false;
                name      = "connecting";
                break;

            case O2GSessionStatusCode.Disconnected:
                connected = false;
                name      = "disconnected";
                break;

            case O2GSessionStatusCode.Disconnecting:
                connected = false;
                name      = "disconnecting";
                break;

            case O2GSessionStatusCode.PriceSessionReconnecting:
                connected = false;
                name      = "price channel reconnecting";
                break;

            case O2GSessionStatusCode.SessionLost:
                connected = false;
                name      = "session has been lost";
                break;

            default:
                connected = false;
                name      = "unknown";
                break;
            }

            if (!connected)
            {
                mReady         = false;
                mTimeConverter = null;
            }

            if (OnSessionStatusChanged != null)
            {
                SessionStatusEventArgs args = new SessionStatusEventArgs(connected, name);
                OnSessionStatusChanged(this, args);
            }
        }