예제 #1
0
        static void ReadPipe()
        {
            byte[] data = { 0, 0, 0, 0, 0 };

            while (Pipes.isConnected())
            {
                do
                {
                    data = Pipes.ReceieveBytes(5);
                }while (data[0] == 0 && Pipes.isConnected());

                switch (data[0])
                {
                case (int)extras.rmessage_val:
                    rmessage = BitConverter.ToInt32(data, 1);
                    if (_form4 != null)
                    {
                        _form4.FUpdate(rmessage);
                    }
                    break;

                case (int)extras.characterx_val:
                    characterx = BitConverter.ToInt32(data, 1);
                    break;

                case (int)extras.charactery_val:
                    charactery = BitConverter.ToInt32(data, 1);
                    break;

                case (int)extras.map_val:
                    map = BitConverter.ToInt32(data, 1);
                    if (_form2 != null)
                    {
                        _form2.MUpdate(map);
                    }
                    break;

                case (int)extras.monstercount_val:
                    monstercount = BitConverter.ToInt32(data, 1);
                    break;

                case ERROR_CODE:
                    Pipes.Disconnect();
                    PipeConnected = false;
                    break;
                }

                if (_form2 != null)
                {
                    _form2.CPUpdate(characterx, charactery);
                }

                data[0] = 0;
            }
        }
예제 #2
0
 static void CheckPipeDisconnect()
 {
     while (ActivePipe)
     {
         if (!PipeConnected)
         {
             Pipes.Reconnect();
         }
         Thread.Sleep(300);
     }
 }
예제 #3
0
 static void InitializePipe()
 {
     if (Pipes.Initialize())
     {
         PipeConnected = true;
         Thread checkPipe = new Thread(ReadPipe);
         checkPipe.Start();
         Thread.Sleep(2000);
         Thread checkDisconnect = new Thread(CheckPipeDisconnect);
         checkDisconnect.Start();
     }
     else
     {
         MessageBox.Show("Pipe failed to start", "Pipe Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
예제 #4
0
 static void SendBytesThread(byte[] data, int count)
 {
     Pipes.SendBytes(data, count);
 }