示例#1
0
        /// <summary>
        /// 发送数据
        /// </summary>
        /// <param name="data">Data.</param>
        public void Send(System.Object data)
        {
            if (m_client == null || !m_client.Client.Connected)
            {
                return;
            }

            byte[] buffer = m_msgProtocol.Encode(data);
            m_kcp.Send(buffer);
            m_updateDirty = true;
            UpdateKcp();
        }
示例#2
0
        /// <summary>
        /// 发送数据
        /// </summary>
        /// <param name="data">Data.</param>
        public void Send(System.Object data)
        {
            if (!m_connected)
            {
                return;
            }

            lock (LOCK_OBJECT) {
                try {
                    byte[] buffer = m_msgProtocol.Encode(data);
                    m_stream.BeginWrite(buffer, 0, buffer.Length, new AsyncCallback(OnWrite), m_client);
                } catch (Exception e) {
                    Close("Error - Send: " + e.Message);
                }
            }
        }