Beispiel #1
0
        private void Init()
        {
            WS.OnRecv        += new Wo1fSocket.PacketReceivedEventHandler(WS_ReceivedEvent);
            WS.OnConnectFail += new Wo1fSocket.OnConnectFailEventHandler(WS_OnConnectFail);
            WS.OnDisconnect  += new Wo1fSocket.OnDisconnectEventHandler(WS_OnDisconnect);
            if (Automate)
            {
                Cmd.Register("Ping", new CommandDelegate(OnPing));
                Cmd.Register("Pong", new CommandDelegate(OnPong));

                Thread T = new Thread(PingThread);
                T.IsBackground = true;
                T.Start();
                CS.AddThread(T);
            }
        }
Beispiel #2
0
        private void DoThreadSettings()
        {
            CS.SysLog("WS::DoThreadSettings(" + Settings.ThreadMode + ");");
            switch (Settings.ThreadMode)
            {
            case Wo1fSocketThreadMode.Async:
                CS.SysLog("Enabling Async socket mode");
                BeginReceive();
                break;

            case Wo1fSocketThreadMode.SingleThreaded:
                /*
                 * if (TickThread != null)
                 *  TickThread.Abort();
                 * TickTimer.Interval = netrate;
                 * TickTimer.OnTick += new Timer.OnTickEventHandler(TickTimer_OnTick);*/
                break;

            case Wo1fSocketThreadMode.MultiThreadedEach:
                if (!Connected)
                {
                    CS.SysLog("Socket not connected - threads not prepared.");
                    return;
                }
                CS.SysLog("Socket thread prepared");
                TickThread = new Thread(new ThreadStart(TickT));
                TickThread.IsBackground = true;
                TickThread.Start();    //sending
                CS.AddThread(TickThread);
                BeginReceive();
                //CS.AddThread(TickThread);
                break;

            case Wo1fSocketThreadMode.MultiThreadCount:
                if (TickThread != null)
                {
                    TickThread.Abort();
                }
                break;
            }
        }