Example #1
0
        private void CloseConnection()
        {
            if (sender == null)
            {
                return;
            }

            senderSema.Wait();

            WriteLog(LogStrings.CloseConnection());
            WriteLog(LogStrings.AttemptingToSendMessage(endMessage));

            byte[] bytes = Encoding.UTF8.GetBytes(endMessage);

            sender.BeginSend(bytes, 0, bytes.Length, 0, new AsyncCallback(CloseConnectionCallback), sender);
        }
Example #2
0
        private void SendTaskToServer()
        {
            if (sender == null)
            {
                return;
            }

            senderSema.Wait();

            string msg = GetMessage();

            byte[] bytes = Encoding.UTF8.GetBytes(msg);

            WriteLog(LogStrings.AttemptingToSendMessage(msg));

            sender.BeginSend(bytes, 0, bytes.Length, 0, new AsyncCallback(SendCallback), sender);
        }