예제 #1
0
 public static string GenerateAccept(string clientKey)
 {
     using (var hasher = SHA1.Create())
     {
         var rawKey = string.Concat(clientKey, ServerKey);
         var txtBuf = Constant.GetBytes(rawKey);
         var encBuf = hasher.ComputeHash(txtBuf);
         return(Convert.ToBase64String(encBuf));
     }
 }
예제 #2
0
 public async Task <bool> SendCloseAsync()
 {
     if (m_state != SocketState.Closed && m_state != SocketState.Closing)
     {
         var payLoad = Constant.GetBytes(Constant.CloseMessage);
         m_requestClose = true;
         return(await SendCloseAsync(payLoad));
     }
     return(false);
 }
예제 #3
0
        private async Task <bool> SendRawAsync(string message)
        {
            var buffer = Constant.GetBytes(message);

            return(await SendRawAsync(buffer));
        }
예제 #4
0
        public async Task <bool> SendStringAsync(string message)
        {
            var buffer = Constant.GetBytes(message);

            return(await SendFrameAsync(OpCode.Text, buffer));
        }