Exemplo n.º 1
0
        private static void SendErrorResponse(IWebSocketConnection socket, string errorInfo)
        {
            Logger.Instance().ErrorWithFormat("{0}:{1}, {2}", socket.ConnectionInfo.ClientIpAddress, socket.ConnectionInfo, errorInfo);

            var header      = string.Format("{0}={1}", ServerDefines.CommandType, ServerDefines.Error);
            var headerBytes = Encoding.UTF8.GetBytes(header);
            var bodyBytes   = string.IsNullOrEmpty(errorInfo) ? null : Encoding.UTF8.GetBytes(errorInfo);
            var bytes       = ResponseDataHelper.GenerateResponseData(headerBytes, bodyBytes);

            socket.Send(bytes);
        }