コード例 #1
0
        public void SendDDS()
        {
            int randomNumber = new Random().Next(0, Int32.MaxValue);

            this.TranslationDictionary = TCP_Protocoll.CreateDicForComm(randomNumber);
            this.Write(new TCP_Protocoll(TCP_Protocoll.HeaderData.DictonaryDefinitionsSeed, randomNumber));
        }
コード例 #2
0
        public void Update()
        {
            Thread.Sleep(10);
            if (!this._socket.Connected)
            {
                _list.Remove(this);
                return;
            }

            if (this._socket.Available > 0)
            {
                TCP_Protocoll antwort = TCP_Protocoll.ReadMessage(this._inpStream, this.TranslationDictionary);

                if (antwort.ProtocolType == TCP_Protocoll.HeaderData.GoodBye)
                {
                    Console.WriteLine("Client {0} says Goodbye. " + antwort.Data, this.ClientID);
                    Disconnect();
                }

                if (antwort.ProtocolType == TCP_Protocoll.HeaderData.DictonaryDefinitionsSeed)
                {
                    this.TranslationDictionary = TCP_Protocoll.CreateDicForComm((int)antwort.Data);
                }

                if (this.Geantwortet != null)
                {
                    this.Geantwortet(this, antwort);
                }
            }
        }