Esempio n. 1
0
        // Send straight away ignoring the queue
        private void SendAsync(Packet cpPacket)
        {
            try {
                bool isProcessed = false;

                if (this.BeforePacketSend != null)
                {
                    this.BeforePacketSend(this, cpPacket, out isProcessed);
                }

                if (isProcessed == false && this.NetworkStream != null)
                {
                    byte[] bytePacket = cpPacket.EncodePacket();

                    lock (this.QueueUnqueuePacketLock) {
                        if (cpPacket.OriginatedFromServer == false && cpPacket.IsResponse == false && this.OutgoingPackets.ContainsKey(cpPacket.SequenceNumber) == false)
                        {
                            this.OutgoingPackets.Add(cpPacket.SequenceNumber, cpPacket);
                        }
                    }

                    this.NetworkStream.BeginWrite(bytePacket, 0, bytePacket.Length, this.SendAsyncCallback, cpPacket);
                }
            }
            catch (SocketException se) {
                this.Shutdown(se);
            }
            catch (Exception e) {
                this.Shutdown(e);
            }
        }
Esempio n. 2
0
        // Send straight away ignoring the queue
        private void SendAsync(Packet cpPacket)
        {
            try {
                bool isProcessed = false;

                if (this.BeforePacketSend != null)
                {
                    this.BeforePacketSend(this, cpPacket, out isProcessed);
                }

                if (isProcessed == false && this.m_nwsStream != null)
                {
                    byte[] a_bBytePacket = cpPacket.EncodePacket();

                    if (cpPacket.OriginatedFromServer == false && cpPacket.IsResponse == false && this.m_dicSentPackets.ContainsKey(cpPacket.SequenceNumber) == false)
                    {
                        this.m_dicSentPackets.Add(cpPacket.SequenceNumber, cpPacket);
                    }

                    this.m_nwsStream.BeginWrite(a_bBytePacket, 0, a_bBytePacket.Length, this.SendAsyncCallback, cpPacket);
                }
            }
            catch (SocketException se) {
                this.Shutdown(se);
            }
            catch (Exception e) {
                this.Shutdown(e);
            }
        }
Esempio n. 3
0
        // Send straight away ignoring the queue
        private void SendAsync(Packet cpPacket) {
            try {

                bool isProcessed = false;

                if (this.BeforePacketSend != null) {
                    this.BeforePacketSend(this, cpPacket, out isProcessed);
                }

                if (isProcessed == false && this.NetworkStream != null) {

                    byte[] bytePacket = cpPacket.EncodePacket();

                    lock (this.QueueUnqueuePacketLock) {
                        if (cpPacket.OriginatedFromServer == false && cpPacket.IsResponse == false && this.OutgoingPackets.ContainsKey(cpPacket.SequenceNumber) == false) {
                            this.OutgoingPackets.Add(cpPacket.SequenceNumber, cpPacket);
                        }
                    }

                    this.NetworkStream.BeginWrite(bytePacket, 0, bytePacket.Length, this.SendAsyncCallback, cpPacket);

                }
            }
            catch (SocketException se) {
                this.Shutdown(se);
            }
            catch (Exception e) {
                this.Shutdown(e);
            }
        }
Esempio n. 4
0
        // Send straight away ignoring the queue
        private void SendAsync(Packet cpPacket) {
            try {

                bool isProcessed = false;

                if (this.BeforePacketSend != null) {
                    this.BeforePacketSend(this, cpPacket, out isProcessed);
                }

                if (isProcessed == false && this.m_nwsStream != null) {

                    byte[] a_bBytePacket = cpPacket.EncodePacket();

                    if (cpPacket.OriginatedFromServer == false && cpPacket.IsResponse == false && this.m_dicSentPackets.ContainsKey(cpPacket.SequenceNumber) == false) {
                        this.m_dicSentPackets.Add(cpPacket.SequenceNumber, cpPacket);
                    }

                    this.m_nwsStream.BeginWrite(a_bBytePacket, 0, a_bBytePacket.Length, this.SendAsyncCallback, cpPacket);

                }
            }
            catch (SocketException se) {
                this.Shutdown(se);
            }
            catch (Exception e) {
                this.Shutdown(e);
            }
        }
        public void SendAsync(Packet cpPacket) {
            try {
                byte[] a_bBytePacket = cpPacket.EncodePacket();

                this.m_tcpStream.BeginWrite(a_bBytePacket, 0, a_bBytePacket.Length, this.SendAsyncCallback, cpPacket);

            }
            catch (SocketException) {
                // TO DO: Error reporting, possibly in a log file.
                this.Shutdown();
            }
            catch (Exception) {
                this.Shutdown();
            }
        }