コード例 #1
0
ファイル: NetStateTcp.cs プロジェクト: ZaneDubya/Monolith
 public override void Send(byte[] buffer, int length, RecordAfterWrite writeBack = null)
 {
     writeBack?.Invoke(buffer, length, true);
     if (_Socket == null || buffer == null || length <= 0)
     {
         return;
     }
     try {
         SendQueue.Gram gram;
         lock (_SendLockMutex) {
             lock (_SendQueue) {
                 gram = _SendQueue.Enqueue(buffer, length);
             }
             if (gram != null && !_sending)
             {
                 _sending = true;
                 try {
                     _Socket.BeginSend(gram.Buffer, 0, gram.Length, SocketFlags.None, _OnSendComplete, _Socket);
                 }
                 catch (Exception ex) {
                     TraceException(ex);
                     Dispose(false);
                 }
             }
         }
     }
     catch (CapacityExceededException) {
         Kernel.WriteLine(TypeName, $"{this} has too much data pending, disconnecting.");
         Dispose(false);
     }
 }
コード例 #2
0
ファイル: HttpsTestClient.cs プロジェクト: ZaneDubya/Monolith
        public void Send(byte[] buffer, int length, RecordAfterWrite writeBack = null)
        {
            writeBack?.Invoke(buffer, length, true);
            if (buffer[0x05] == (byte)EHandshake.ServerHelloDone)
            {
                _Server.ReceiveHttps(this, ClientKeyExchange0, ClientKeyExchange0.Length);
                _Server.ReceiveHttps(this, ClientChangeCipherSpecAndConfirm0, ClientChangeCipherSpecAndConfirm0.Length);
            }
            else if (buffer[0x05] == 0x2D)   // finished
            {
                _Server.ReceiveHttps(this, ClientFirstDataPacket0, ClientFirstDataPacket0.Length);
            }
            else if (buffer[0x00] == 23)   // application data

            {
            }
        }