public bool Join(string webServiceUrl, string userName, string sessionKey, out string message)
        {
            SessionId = sessionKey;
            _seWs     = new SeNetworkService(webServiceUrl);
            Users     = new List <SeNetworkService.SeUser>();
            var joinRequest = new SeNetworkService.JoinRequest()
            {
                SessionId = sessionKey,
                UserName  = userName
            };
            var joinResponse = _seWs.Join(joinRequest);

            message = joinResponse.Message;
            if (joinResponse.Message != "OK")
            {
                return(false);
            }

            Subtitle = new Subtitle();
            var getSubtitleRequest = new SeNetworkService.GetSubtitleRequest
            {
                SessionId = sessionKey
            };
            var getSubtitleResponse = _seWs.GetSubtitle(getSubtitleRequest);

            foreach (var sequence in getSubtitleResponse.Subtitle)
            {
                Subtitle.Paragraphs.Add(new Paragraph(WebUtility.HtmlDecode(sequence.Text).Replace("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds));
            }

            _fileName = getSubtitleResponse.FileName;

            OriginalSubtitle = new Subtitle();
            var getOriginalSubtitleRequest = new SeNetworkService.GetOriginalSubtitleRequest
            {
                SessionId = sessionKey
            };
            var getOriginalSubtitleResponse = _seWs.GetOriginalSubtitle(getOriginalSubtitleRequest);

            if (getOriginalSubtitleResponse.Subtitle != null)
            {
                foreach (var sequence in getOriginalSubtitleResponse.Subtitle)
                {
                    OriginalSubtitle.Paragraphs.Add(new Paragraph(WebUtility.HtmlDecode(sequence.Text).Replace("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds));
                }
            }

            SessionId   = sessionKey;
            CurrentUser = joinResponse.Users.Last();
            foreach (var user in joinResponse.Users)
            {
                Users.Add(user);
            }

            ReloadFromWs();
            _timerWebService.Start();
            return(true);
        }
        public void StartServer(string baseUrl, string sessionKey, string userName, string fileName, out string message)
        {
            SessionId = sessionKey;
            _userName = userName;
            _fileName = fileName;
            var list = new List <SeNetworkService.SeSequence>();

            foreach (var 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 (var 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(baseUrl);
            var request = new SeNetworkService.StartRequest()
            {
                SessionId        = sessionKey,
                FileName         = fileName,
                OriginalSubtitle = originalSubtitle,
                Subtitle         = list,
                UserName         = userName
            };

            var response = _seWs.Start(request);

            CurrentUser = response.User;
            message     = response.Message;
            Users       = new List <SeNetworkService.SeUser> {
                response.User
            };
            if (response.Message == "OK")
            {
                _timerWebService.Start();
            }
        }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_timerWebService != null)
         {
             _timerWebService.Dispose();
             _timerWebService = null;
         }
         _seWs = null;
     }
 }