Пример #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);   
     }
 }
Пример #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);
     }
 }
Пример #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();
 }
Пример #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));
 }
Пример #7
0
 void IProtocolProcessor.InitializeClientHandshake(NetContext context, Connection connection)
 {
     InitializeClientHandshake(context, connection);
 }
Пример #8
0
 void IProtocolProcessor.Send(NetContext context, Connection connection, object message)
 {
     Send(context, connection, message);
 }
Пример #9
0
 protected abstract void Send(NetContext context, Connection connection, object message);
Пример #10
0
 protected abstract int ProcessIncoming(NetContext context, Connection connection, System.IO.Stream incomingBuffer);
Пример #11
0
 protected virtual void InitializeOutbound(NetContext context, Connection connection) { }
Пример #12
0
 protected virtual void GracefulShutdown(NetContext context, Connection connection)
 {
     EnqueueFrame(context, ShutdownFrame.Default);
     connection.PromptToSend(context);
 }
Пример #13
0
 void IProtocolProcessor.InitializeOutbound(NetContext context, Connection connection)
 {
     InitializeOutbound(context, connection);
 }
Пример #14
0
 void IProtocolProcessor.GracefulShutdown(NetContext context, Connection connection)
 {
     GracefulShutdown(context, connection);
 }
Пример #15
0
 protected virtual void InitializeClientHandshake(NetContext context, Connection connection)
 {
     /* nothing to do */
 }
Пример #16
0
 void IFrame.Write(NetContext context, Connection connection, Stream stream)
 {
     Write(context, connection, stream);
 }
Пример #17
0
 int IProtocolProcessor.ProcessIncoming(NetContext context, Connection connection,
                                        System.IO.Stream incomingBuffer)
 {
     return ProcessIncoming(context, connection, incomingBuffer);
 }