internal static bool PeekAddonUpdates(int _MinutesSinceLastPeek) { VF.NetworkClient netClient = new VF.NetworkClient(g_Host, g_Port); netClient.WaitForConnect(TimeSpan.FromSeconds(60)); try { { VF.NetworkOutgoingMessage newMessage = netClient.CreateMessage(); WLN_RequestPacket_AddonUpdateInfoPeek request = new WLN_RequestPacket_AddonUpdateInfoPeek(); request.UserID = Settings.UserID; request.LauncherVersion = StaticValues.LauncherVersion; request.MinutesSinceLastPeek = _MinutesSinceLastPeek; newMessage.WriteByte((byte)WLN_PacketType.Request_AddonUpdateInfoPeek); newMessage.WriteClass(request); netClient.SendMessage(newMessage); } WLN_ResponsePacket_AddonUpdateInfoPeek response = new WLN_ResponsePacket_AddonUpdateInfoPeek(); if (netClient.RecvPacket_VF(WLN_PacketType.Response_AddonUpdateInfoPeek, out response) == true) { if (response.AddonUpdatesAvailable != null) { return(response.AddonUpdatesAvailable.Count > 0); } } } finally { netClient.Disconnect(); netClient = null; } return(false); }
internal static void SendAddonData_Dispose() { if (sm_Client != null) { sm_Client.Disconnect(); sm_Client = null; } }
internal static List <WLN_ResponsePacket_GetNewsSince> GetNewsSince(DateTime _LastNewsDateTime, List <string> _NewsSourcesWanted) { List <WLN_ResponsePacket_GetNewsSince> newsPackets = new List <WLN_ResponsePacket_GetNewsSince>(); VF.NetworkClient netClient = new VF.NetworkClient(g_Host, g_Port); netClient.WaitForConnect(TimeSpan.FromSeconds(60)); try { { VF.NetworkOutgoingMessage newMessage = netClient.CreateMessage(); WLN_RequestPacket_GetNewsSince request = new WLN_RequestPacket_GetNewsSince(); request.LastNewsDateTime = _LastNewsDateTime; request.NewsSources = _NewsSourcesWanted; newMessage.WriteByte((byte)WLN_PacketType.Request_GetNewsSince); newMessage.WriteClass(request); netClient.SendMessage(newMessage); } if (netClient.RecvPacket_VF(WLN_PacketType.Response_GetNewsSince, out newsPackets) == true) { return(newsPackets); } else { newsPackets = new List <WLN_ResponsePacket_GetNewsSince>(); } } catch (Exception) { newsPackets = new List <WLN_ResponsePacket_GetNewsSince>(); } finally { netClient.Disconnect(); netClient = null; } return(newsPackets); }
internal static List <string> SendAddonData(string _UserID, string _AddonName, WowVersionEnum _WowVersion, string _ClearLuaVariableName, int _LuaVariableDataLengthThreshold, out bool _SentAll) { var savedVariableFiles = WowUtility.GetSavedVariableFilePaths(_AddonName, _WowVersion);//For Accounts only _LuaVariableDataLengthThreshold = _LuaVariableDataLengthThreshold + 12 /*newlines = {} osv osv*/ + _ClearLuaVariableName.Length; VF.NetworkClient netClient = sm_Client; if (netClient != null && netClient.IsConnected() == false) { netClient.Disconnect(); netClient = null; } List <string> sentAddonFiles = new List <string>(); _SentAll = true;//Default läge try { foreach (var luaFilePath in savedVariableFiles) { string luaFileData = System.IO.File.ReadAllText(luaFilePath); string resultFileData = ""; string variableData = ""; if (WowUtility.ExtractLuaVariableFromFile(luaFileData, _ClearLuaVariableName, out resultFileData, out variableData) == true) { if (variableData.Length < _LuaVariableDataLengthThreshold) { continue; } if (netClient == null) { Logger.ConsoleWriteLine("Trying to connect to server...", ConsoleColor.Gray); netClient = new VF.NetworkClient(g_Host, g_Port); //realmplayers.com Logger.ConsoleWriteLine("Connected to server!", ConsoleColor.Green); } WLN_UploadPacket_AddonData addonData = new WLN_UploadPacket_AddonData(); addonData.AddonName = _AddonName; addonData.UserID = _UserID; addonData.FileStatus = WowUtility.GetFileStatus(luaFilePath); addonData.Data = luaFileData; var newMessage = netClient.CreateMessage(); newMessage.WriteByte((byte)WLN_PacketType.Upload_AddonData); newMessage.WriteClass(addonData); netClient.WaitForConnect(TimeSpan.FromSeconds(60)); netClient.SendMessage(newMessage); Logger.ConsoleWriteLine("Sent SavedVariables file \"" + luaFilePath + "\". Waiting for Response...", ConsoleColor.Gray); WLN_UploadPacket_SuccessResponse response; if (netClient.RecvPacket_VF(WLN_PacketType.Upload_SuccessResponse, out response, TimeSpan.FromSeconds(60)) == true) { Logger.ConsoleWriteLine("Received Response. Data was sent successfully!. Deleting old data", ConsoleColor.Gray); sentAddonFiles.Add(luaFilePath); if (response.MessageToUser != "") { Utility.MessageBoxShow(response.MessageToUser, "Message from Server"); } //TODO: Do something with "response.MessageToUser" System.IO.File.WriteAllText(luaFilePath, resultFileData); //Save the lua file with the variable cleared Logger.ConsoleWriteLine("Operation Successfull! Preparing for next file.", ConsoleColor.Green); } else { Logger.ConsoleWriteLine("Operation Failed! Preparing for next file.", ConsoleColor.Red); _SentAll = false; } } else { } } } catch (Exception ex) { Logger.LogException(ex); _SentAll = false; } finally { if (_SentAll == false) { if (netClient != null) { netClient.Disconnect(); netClient = null; } } sm_Client = netClient; } return(sentAddonFiles); }
internal static List <AddonUpdateInfo> GetAddonUpdateInfos(List <string> _AddonNames, WowVersionEnum _WowVersion) { VF.NetworkClient netClient = new VF.NetworkClient(g_Host, g_Port); List <AddonUpdateInfo> retList = new List <AddonUpdateInfo>(); try { //VF.NetworkIncommingMessage msg; { VF.NetworkOutgoingMessage newMessage = netClient.CreateMessage(); WLN_RequestPacket_AddonUpdateInfoNew request = new WLN_RequestPacket_AddonUpdateInfoNew(); request.UserID = Settings.UserID; request.LauncherVersion = StaticValues.LauncherVersion; request.WowVersion = _WowVersion; for (int i = 0; i < _AddonNames.Count; ++i) { var addonUpdateInfo = new WLN_RequestPacket_AddonUpdateInfo(); addonUpdateInfo.AddonName = _AddonNames[i]; var addonInfo = InstalledAddons.GetAddonInfo(_AddonNames[i], _WowVersion); if (addonInfo != null) { addonUpdateInfo.CurrentVersion = addonInfo.m_VersionString; } else { addonUpdateInfo.CurrentVersion = "0.0"; } request.Addons.Add(addonUpdateInfo); } newMessage.WriteByte((byte)WLN_PacketType.Request_AddonUpdateInfoNew); newMessage.WriteClass(request); netClient.SendMessage(newMessage); } List <WLN_ResponsePacket_AddonUpdateInfo> recvAddonUpdateInfos = null; if (netClient.RecvPacket_VF(WLN_PacketType.Response_AddonUpdateInfo, out recvAddonUpdateInfos) == true) { foreach (var recvAddonUpdateInfo in recvAddonUpdateInfos) { if (recvAddonUpdateInfo.AddonName == "null") { continue; } AddonUpdateInfo addonUpdateInfo = new AddonUpdateInfo(); addonUpdateInfo.AddonName = recvAddonUpdateInfo.AddonName; addonUpdateInfo.InstalledAddonInfo = InstalledAddons.GetAddonInfo(recvAddonUpdateInfo.AddonName, _WowVersion); addonUpdateInfo.CurrentVersion = recvAddonUpdateInfo.CurrentVersion; addonUpdateInfo.UpdateVersion = recvAddonUpdateInfo.UpdateVersion; addonUpdateInfo.UpdateDescription = recvAddonUpdateInfo.UpdateDescription; addonUpdateInfo.AddonPackageDownloadFTP = recvAddonUpdateInfo.AddonPackageDownloadFTP; addonUpdateInfo.ClearAccountSavedVariablesRequired = recvAddonUpdateInfo.ClearAccountSavedVariablesRequired; addonUpdateInfo.UpdateSubmitter = recvAddonUpdateInfo.UpdateSubmitter; addonUpdateInfo.UpdateImportance = recvAddonUpdateInfo.UpdateImportance; addonUpdateInfo.MoreInfoSite = recvAddonUpdateInfo.MoreInfoSite; retList.Add(addonUpdateInfo); } } } finally { netClient.Disconnect(); } return(retList); }