/// <summary>Generates a header, then writes the header, payload, and /// trailer to the wire.</summary> /// <param name="f">the Frame to send.</param> /// <returns>boolean true if the frame was sent, false otherwise.</returns> /// /// <exception cref="BEEPException" /> /// /// @todo make this one write operation later. protected internal override void sendFrame(Frame f) { try { System.IO.Stream os; lock (this) { if(socket != null) { os = socket.GetStream(); } else { throw new SessionAbortedException(); } } lock (writerLock) { /* Inspite of the extra data copy if is faster to have * a single call to write() (at least with the JVMs we * have tested with). */ BufferSegment[] bs = f.getBytes(); int n = 0; for (int i = 0; i < bs.Length; ++i) { n += bs[i].Length; } if (n > outputBuf.Length) { outputBuf = new byte[n]; } int off = 0; for (int i = 0; i < bs.Length; ++i) { Array.Copy(bs[i].Data, bs[i].Offset, outputBuf, off, bs[i].Length); off += bs[i].Length; } if (log.isTraceEnabled()) { log.trace("C:" + System.Text.Encoding.ASCII.GetString(outputBuf)); } os.Write(outputBuf, 0, n); os.Flush(); // has no effect on NetworkStream ! } } catch (System.Exception e) { throw new BEEPException(e); } }
/// <summary>Implement this method to send frames and on the sub-classed transport.</summary> /// <param name="f">BEEP frame to send. /// </param> /// <exception cref="BEEPException" /> protected internal abstract void sendFrame(Frame f);
/// <summary>Method postFrame</summary> /// <param name="f"></param> /// <exception cref="BEEPException" /> protected internal virtual bool postFrame(Frame f) { try { return ops[(int)state].postFrame(this, f); } catch (BEEPException e) { this.terminate(e.Message); return false; } catch (System.Exception e) { log.error("Error posting frame", e); this.terminate("Uncaught exception, terminating session"); return false; } }
public virtual bool postFrame(SessionImpl s, Frame f) { // If we're in an error state log.debug("Dropping a frame because the Session state is " + "no longer active."); return false; }
public virtual bool postFrame(SessionImpl s, Frame f) { return ((ChannelImpl) f.Channel).postFrame(f); }
public virtual bool postFrame(SessionImpl s, Frame f) { // If we're in a PRE-GREETING state // only handle one frame at a time... // to avoid processing post-greeting // frames before the greeting has been // fully handled. lock (s) { return ((ChannelImpl) f.Channel).postFrame(f); } }