Esempio n. 1
0
 public override void OnClose()
 {
     SocketCollection.Remove(this);
     if (Partner != null)
     {
         var request = new
         {
             Type = "PartnerClose"
         };
         Partner.Send(Json.Encode(request));
         Partner.Close();
         Partner.Partner = null;
         Partner         = null;
     }
     if (ConnectionType == ConnectionTypes.ClientService)
     {
         Save();
     }
 }
Esempio n. 2
0
        public override void OnError()
        {
            SocketCollection.Remove(this);
            if (Partner != null)
            {
                var request = new
                {
                    Type = "PartnerError"
                };
                Partner.Send(Json.Encode(request));
                Partner.Close();
                Partner.Partner = null;
                Partner         = null;
            }
            if (ConnectionType == ConnectionTypes.ClientService)
            {
                Save();
            }
            var filePath = Path.Combine(Utilities.App_Data, "WebSocket_Errors", DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString().PadLeft(2, '0'), DateTime.Now.Day.ToString().PadLeft(2, '0') + ".txt");

            if (!Directory.Exists(Path.GetDirectoryName(filePath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(filePath));
            }
            var jsonError = new
            {
                Timestamp  = DateTime.Now.ToString(),
                Message    = Error?.Message,
                InnerEx    = Error?.InnerException?.Message,
                Source     = Error?.Source,
                StackTrace = Error?.StackTrace,
            };
            var error = Json.Encode(jsonError) + Environment.NewLine;

            File.AppendAllText(filePath, error);
        }