public void SendHandle(ByteArray data) { try { var header = new Header(data); if (YoponSetting.I.IsDebugMode && header.Type == Header.TYPE_COMMAND) { var commandId = header.CommandId; var fieldName = Methods.GetFieldName(commandId); var logPath = YoponSetting.DebugLogFile; var message = $"[INFO METHOD] {fieldName}"; if (DESCipher.IsEncryptData(header.Body, Key)) { message += " (ENCRYPTED)"; } Logger.OutputAtBackground(logPath, message); } } catch (Exception ex) { Logger.OutputAtBackground( YoponSetting.DebugLogFile, $"[ERROR] {ex.ToString()}"); } WebSocketProxy.Send(data); }
public void SendHandle(ByteArray data) { try { var header = new Header(data); var input = new ByteArray(header.Body); if (YoponSetting.I.IsDebugMode && header.Type == Header.TYPE_COMMAND) { var commandId = header.CommandId; var fieldName = Methods.GetFieldName(commandId); var logPath = YoponSetting.DebugLogFile; var message = $"[CHAT METHOD] {fieldName}"; if (DESCipher.IsEncryptData(header.Body, Key)) { message += " (ENCRYPTED)"; } Logger.OutputAtBackground(logPath, message); } if (header.CommandId == ChatMethod.TALK) { input.Decrypt(Key); var message = input.ReadUTF().ToLower(); var color = ActiveUser.TalkBGColor; if (ActiveUser.TalkBGColor != System.Drawing.Color.White) { var colorToUint = (uint)(color.R << 16 | color.G << 8 | color.B); var talk = new ByteArray(); talk.WriteUTF(message); talk.WriteUnsignedInt(colorToUint); talk.WriteUnsignedInt(colorToUint); talk.Encrypt(Key); header.Body = talk.Bytes; header.Write(data); } if (message == "/log") { var log = ActiveUser.ChatLogFileDir; Directory.CreateDirectory(log); Process.Start("explorer.exe", log); var head = new Header(); head.CommandId = ChatMethod.CANCEL_TYPING; head.Write(data); } else if (message == "/debug") { var packet = new Header(); var bytes = new ByteArray(); if (YoponSetting.I.IsDebugMode) { YoponSetting.I.HasDownloadModule = false; YoponSetting.I.IsDebugMode = false; bytes.WriteUTF("デバッグモードが無効になりました"); } else { YoponSetting.I.HasDownloadModule = true; YoponSetting.I.IsDebugMode = true; bytes.WriteUTF("デバッグモードが有効になりました"); } packet.CommandId = ChatMethod.ALERT_RESULT; packet.Body = bytes.Bytes; WebSocketProxy.Recv(packet.ToArray()); var head = new Header(); head.CommandId = ChatMethod.CANCEL_TYPING; head.Write(data); } } else if (header.CommandId == ChatMethod.MOVE) { if (ActiveUser.IsOneClickTeleport) { var head = new Header() { CommandId = ChatMethod.MOVE_END }; input.Decrypt(Key); input.Position = input.Length; input.WriteShort(0); // dir input.Encrypt(Key); head.Body = input.Bytes; head.Write(data); } } } catch (Exception ex) { Logger.OutputAtBackground( YoponSetting.DebugLogFile, $"[ERROR] {ex.ToString()}"); } WebSocketProxy.Send(data); }