/// <summary>Sends a message of type ERR.</summary> /// <param name="code"><code>code</code> attibute in <code>error</code> element.</param> /// <param name="diagnostic">Message for <code>error</code> element.</param> /// <param name="xmlLang"><code>xml:lang</code> attibute in <code>error</code> /// element.</param> /// <seealso cref="MessageStatus"></seealso> /// <returns>MessageStatus</returns> /// /// <exception cref="BEEPException">if an error is encoutered or if messageType is /// not MESSAGE_TYPE_MSG.</exception> public virtual MessageStatus sendERR(BEEPStatusCode code, string diagnostic, string xmlLang) { throw new BEEPException(NOT_MESSAGE_TYPE_MSG); }
/// <summary>The Initiator Oriented close channel call...but this one is not an /// external call, it's invoked from Channel.close();</summary> /// <param name="channel"></param> /// <param name="code"></param> /// <param name="xmlLang"></param> /// <exception cref="BEEPException" /> internal virtual void closeChannel(ChannelImpl channel, BEEPStatusCode code, string xmlLang) { // Construct Message System.Text.StringBuilder closeBuffer = new System.Text.StringBuilder(); closeBuffer.Append("<close number='"); closeBuffer.Append(channel.NumberAsString); closeBuffer.Append("' code='"); closeBuffer.Append(code); if ((object) xmlLang != null) { closeBuffer.Append("' xml:lang='"); closeBuffer.Append(xmlLang); } closeBuffer.Append("' />"); // Lock necessary because we have to know the msgNo // before we send the message, in order to be able // to associate the reply with this start request CloseReplyListener reply = new CloseReplyListener(this, channel); lock (reply) { OutputDataStream ds = new ByteOutputDataStream(MimeHeaders.BEEP_XML_CONTENT_TYPE, System.Text.Encoding.ASCII.GetBytes(closeBuffer.ToString())); this.zero.sendMSG(ds, reply); try { System.Threading.Monitor.Wait(reply); } catch (System.Threading.ThreadInterruptedException e) { log.error("Error waiting for reply", e); throw new BEEPException("Interrupted waiting for reply"); } } // check the channel state and return the appropriate exception if (reply.isError()) { throw reply.getError(); } if (channel.getState() != core.ChannelState.STATE_CLOSED) { throw new BEEPException("Error channel state (" + channel.getState() + ")"); } fireChannelClosed(channel); }