Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            while (!IsProcessRunning("TS3W"))
            {
            }
            System.Threading.Thread.Sleep(10000);
            Process process = Process.GetProcessesByName("TS3W")[0];

            MessageBuffer.isConnected = MessageBuffer.Connect(process.Id, (ulong)MessageIDs.BufferFindID);
            byte[] buffer = new byte[MessageBuffer.BufferSize];

            byte[] ID       = System.BitConverter.GetBytes((ulong)MessageIDs.HandShakeRequest);
            int    longSize = sizeof(ulong);

            for (int i = 0; i < longSize; i++)
            {
                buffer[i] = ID[i];
            }
            MessageBuffer.WriteMessage(buffer);
        }
        private void SendMessages()
        {
            byte[] messages     = new byte[BufferSize];
            int    messageIndex = longSize + 1;

            for (int i = 0; i < sendBuffer.Count; i++)
            {
                for (int b = 0; b < sendBuffer[i].Length; b++)
                {
                    messages[messageIndex + b] = sendBuffer[i][b];
                }
                messageIndex += sendBuffer[i].Length;
            }
            messages[longSize] = (byte)sendBuffer.Count;
            byte[] senderBytes = BitConverter.GetBytes((ulong)SenderIDs.TcpController);
            for (int i = 0; i < senderBytes.Length; i++)
            {
                messages[i] = senderBytes[i];
            }
            sendBuffer.Clear();
            MessageBuffer.WriteMessage(messages);
        }
        public void Connect()
        {
            while (!IsProcessRunning("TS3W"))
            {

            }
            Thread.Sleep(10000);
            Process process = Process.GetProcessesByName("TS3W")[0];
            while (!MessageBuffer.Connect(process.Id, (ulong)MessageIDs.BufferFindID))
            {
                System.Threading.Thread.Sleep(100);
            }
            isConnected = true;

            RequestHandShake();
            WaitForHandshake();
            ///////////////////////////////////////////Temp start game message
            byte[] buffer = new byte[BufferSize];
            for (int i = 0; i < buffer.Length; i++)
            {
                buffer[i] = 1;
            }
            byte[] senderID = System.BitConverter.GetBytes((ulong)SenderIDs.TcpController);
            byte[] messageID = System.BitConverter.GetBytes((ulong)MessageIDs.StartGame);
            for (int i = 0; i < longSize; i++)
            {
                buffer[i] = senderID[i];//SenderID
            }
            buffer[longSize] = 1;//Num messages
            for (int i = 0; i < longSize; i++)
            {
                buffer[longSize + i + 1] = messageID[i];//Message
            }
            MessageBuffer.WriteMessage(buffer);
            ///////////////////////////////////////////Temp start game message

        }
Exemple #4
0
 public Form1()
 {
     InitializeComponent();
     MessageBuffer.Initialize(MessageBuffer.BufferSize);
 }
Exemple #5
0
 public void SendMessages(byte[] messages)
 {
     MessageBuffer.WriteMessage(messages);
 }
Exemple #6
0
 public BufferSocket()
 {
     MessageBuffer.Initialize(BufferSize);
 }
 public BufferSocket()
 {
     MessageBuffer.Initialize(BufferSize);
     BufferThread = new Thread(RunThread);
 }