public bool Join(string webServiceUrl, string userName, string sessionKey, out string message) { SessionId = sessionKey; _seWs = new SeNetworkService.SeService { Url = webServiceUrl, Proxy = Utilities.GetProxy() }; Users = new List <SeNetworkService.SeUser>(); var users = _seWs.Join(sessionKey, userName, out message); if (message != "OK") { return(false); } string tempFileName; Subtitle = new Subtitle(); foreach (var sequence in _seWs.GetSubtitle(sessionKey, out tempFileName, out _)) { Subtitle.Paragraphs.Add(new Paragraph(WebUtility.HtmlDecode(sequence.Text).Replace("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds)); } FileName = tempFileName; OriginalSubtitle = new Subtitle(); var sequences = _seWs.GetOriginalSubtitle(sessionKey); if (sequences != null) { foreach (var sequence in sequences) { OriginalSubtitle.Paragraphs.Add(new Paragraph(WebUtility.HtmlDecode(sequence.Text).Replace("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds)); } } SessionId = sessionKey; CurrentUser = users[users.Length - 1]; // me foreach (var user in users) { Users.Add(user); } ReloadFromWs(); _timerWebService.Start(); return(true); }
public void StartServer(string webServiceUrl, string sessionKey, string userName, string fileName, out string message) { SessionId = sessionKey; UserName = userName; FileName = fileName; var list = new List <SeNetworkService.SeSequence>(); foreach (Paragraph p in Subtitle.Paragraphs) { list.Add(new SeNetworkService.SeSequence { StartMilliseconds = (int)p.StartTime.TotalMilliseconds, EndMilliseconds = (int)p.EndTime.TotalMilliseconds, Text = WebUtility.HtmlEncode(p.Text.Replace(Environment.NewLine, "<br />")) }); } var originalSubtitle = new List <SeNetworkService.SeSequence>(); if (OriginalSubtitle != null) { foreach (Paragraph p in OriginalSubtitle.Paragraphs) { originalSubtitle.Add(new SeNetworkService.SeSequence { StartMilliseconds = (int)p.StartTime.TotalMilliseconds, EndMilliseconds = (int)p.EndTime.TotalMilliseconds, Text = WebUtility.HtmlEncode(p.Text.Replace(Environment.NewLine, "<br />")) }); } } _seWs = new SeNetworkService.SeService { Url = webServiceUrl, Proxy = Utilities.GetProxy() }; SeNetworkService.SeUser user = _seWs.Start(sessionKey, userName, list.ToArray(), originalSubtitle.ToArray(), fileName, out message); CurrentUser = user; Users = new List <SeNetworkService.SeUser> { user }; if (message == "OK") { _timerWebService.Start(); } }
public void AddToWsUserLog(SeNetworkService.SeUser user, int pos, string action, bool updateUi) { for (int i = 0; i < UpdateLog.Count; i++) { if (UpdateLog[i].Index == pos) { UpdateLog.RemoveAt(i); break; } } UpdateLog.Add(new UpdateLogEntry(0, user.UserName, pos, action)); if (updateUi) { OnUpdateUserLogEntries?.Invoke(null, null); } }