예제 #1
0
        /// ///////////////////////////////////////////////

        /// Message functions /////////////////////////////
        private static bool SendMessage(MessageWrapper message)
        {
            if (message == null)
            {
                plugin.Error("Tried to send message but it was null.");
                return(true);
            }

            // Abort if client is dead
            if (socket == null || networkStream == null || !socket.Connected)
            {
                plugin.VerboseWarn("Error sending message '" + message.MessageCase.ToString() + "' to bot: Not connected.");
                return(false);
            }

            // Try to send the message to the bot
            try
            {
                message.WriteDelimitedTo(networkStream);
                plugin.Debug("Sent message '" + message.MessageCase.ToString() + "' to bot.");
                return(true);
            }
            catch (Exception e)
            {
                plugin.Error("Error sending message '" + message.MessageCase.ToString() + "' to bot.");
                plugin.Error(e.ToString());
                if (!(e is InvalidOperationException || e is ArgumentNullException || e is SocketException))
                {
                    throw;
                }
            }
            return(false);
        }
예제 #2
0
 public static void SendMessage(MessageWrapper message)
 {
     message.WriteDelimitedTo(networkStream);
 }