Exemplo n.º 1
0
        /// <summary>
        /// 接收成功 相应
        /// </summary>
        /// <param name="msg"></param>
        public void SendSuccess(string msg)
        {
            _Context.Response.ContentType = "application/json";
            string result = new SuccessInfo(this, msg).ToJsonString();

            byte[] data = UTF8Encoding.Default.GetBytes(result);
            _Context.Response.Body.Write(data, 0, data.Length);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 相应接收成功消息
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        private async Task SendSuccess(string msg, int curLength = 0)
        {
            SuccessInfo result = new SuccessInfo(_file);

            result.curSize   = curSize;
            result.curLength = curLength;
            result.msg       = msg;
            ArraySegment <byte> data = new ArraySegment <byte>(Encoding.UTF8.GetBytes(result.ToJson()));
            await _socket.SendAsync(data, WebSocketMessageType.Text, true, CancellationToken.None);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 接收成功 相应
        /// </summary>
        /// <param name="msg"></param>
        public void SendSuccess(string msg)
        {
            _Context.Response.ContentType = "application/json";
            SuccessInfo result = new SuccessInfo(this, msg);

            if (OnSuccess != null)
            {
                OnSuccess(result);
            }
            byte[] data = UTF8Encoding.Default.GetBytes(result.ToJson());
            _Context.Response.Body.WriteAsync(data, 0, data.Length);
        }