Ejemplo n.º 1
0
 protected virtual void Write(NetContext context, Connection connection, Stream stream)
 {
     byte[] buffer = null;
     try
     {
         buffer = context.GetBuffer();
         buffer[0] = (byte) (value >> 24);
         buffer[1] = (byte) (value >> 16);
         buffer[2] = (byte) (value >> 8);
         buffer[3] = (byte) (value);
         stream.Write(buffer, 0, 4);
     } finally
     {
         context.Recycle(buffer);   
     }
 }
Ejemplo n.º 2
0
 protected virtual void Write(NetContext context, Connection connection, Stream stream)
 {
     byte[] buffer = null;
     try
     {
         buffer = context.GetBuffer();
         if(encoding.GetMaxByteCount(value.Length) <= buffer.Length || encoding.GetByteCount(value) <= buffer.Length)
         {
             int len = encoding.GetBytes(value, 0, value.Length, buffer, 0);
             stream.Write(buffer, 0, len);
         } else
         { // need to do things the hard way...
             throw new NotImplementedException();
         }
     }
     finally
     {
         context.Recycle(buffer);
     }
 }
Ejemplo n.º 3
0
 internal static string GetIdent(Connection connection)
 {
     var builder = new StringBuilder(GetAuditTimestamp()).Append(' ');
     if(connection == null) builder.Append("??conn??");
     else
     {
         int id = connection.connectionId;
         builder.Append(((byte) (id >> 24)).ToString("x2"))
             .Append(((byte) (id >> 16)).ToString("x2"))
             .Append(((byte) (id >> 8)).ToString("x2"))
             .Append(((byte) (id)).ToString("x2"));
     }
     return builder.ToString();
 }
Ejemplo n.º 4
0
 protected virtual void Write(NetContext context, Connection connection, Stream stream)
 {
     stream.Write(value, 0, value.Length);
 }
 protected override int ProcessIncoming(NetContext context, Connection connection, System.IO.Stream incomingBuffer)
 {
     throw new NotSupportedException(); // not expecting more incoming
 }
 protected override void Send(NetContext context, Connection connection, object message)
 {
     EnqueueFrame(context, new StringFrame((string)message));
 }
Ejemplo n.º 7
0
 void IProtocolProcessor.InitializeClientHandshake(NetContext context, Connection connection)
 {
     InitializeClientHandshake(context, connection);
 }
Ejemplo n.º 8
0
 void IProtocolProcessor.Send(NetContext context, Connection connection, object message)
 {
     Send(context, connection, message);
 }
Ejemplo n.º 9
0
 protected abstract void Send(NetContext context, Connection connection, object message);
Ejemplo n.º 10
0
 protected abstract int ProcessIncoming(NetContext context, Connection connection, System.IO.Stream incomingBuffer);
Ejemplo n.º 11
0
 protected virtual void InitializeOutbound(NetContext context, Connection connection) { }
Ejemplo n.º 12
0
 protected virtual void GracefulShutdown(NetContext context, Connection connection)
 {
     EnqueueFrame(context, ShutdownFrame.Default);
     connection.PromptToSend(context);
 }
Ejemplo n.º 13
0
 void IProtocolProcessor.InitializeOutbound(NetContext context, Connection connection)
 {
     InitializeOutbound(context, connection);
 }
Ejemplo n.º 14
0
 void IProtocolProcessor.GracefulShutdown(NetContext context, Connection connection)
 {
     GracefulShutdown(context, connection);
 }
Ejemplo n.º 15
0
 protected virtual void InitializeClientHandshake(NetContext context, Connection connection)
 {
     /* nothing to do */
 }
Ejemplo n.º 16
0
 void IFrame.Write(NetContext context, Connection connection, Stream stream)
 {
     Write(context, connection, stream);
 }
Ejemplo n.º 17
0
 int IProtocolProcessor.ProcessIncoming(NetContext context, Connection connection,
                                        System.IO.Stream incomingBuffer)
 {
     return ProcessIncoming(context, connection, incomingBuffer);
 }