private void SendBaseOptions(MossRequest request) { this.SendOption(AppSettings.UserIdOption, this._userId); this.SendOption(AppSettings.DirectoryModeOption, request.IsDirectoryMode); this.SendOption(AppSettings.ExperimentalOption, request.IsExperimental); this.SendOption(AppSettings.MaximumMatchesOption, request.MaximumMatches); this.SendOption(AppSettings.MaximumFilesToShowOption, request.MaximumFilesToShow); }
private string SendFinalOptions(MossRequest request) { var result = new byte[512]; this.SendOption(AppSettings.QueryOption, request.Comments); this._socket.Receive(result); this.SendOption(AppSettings.EndOption, string.Empty); return(Encoding.UTF8.GetString(result)); }
private void SendFiles(MossRequest request) { foreach (var file in request.BaseFileNames) { this.SendFile(request.Language, file, 0); } var submittedFilesCount = request.FileNames.Count(); for (int i = 0; i < submittedFilesCount; i++) { this.SendFile(request.Language, request.FileNames.ElementAt(i), i + 1); } }
public MossResponse SendRequest(MossRequest request) { var endpoint = GetEndPoint(); using (this._socket = new Socket(endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)) { try { this._socket.Connect(endpoint); this.SendBaseOptions(request); this.SendFiles(request); var resultUrl = this.SendFinalOptions(request); if (Uri.TryCreate(resultUrl, UriKind.Absolute, out Uri url)) { return(new MossResponse { ResultUrl = url.ToString(), IsValid = true }); } return(new MossResponse { IsValid = false }); } catch (Exception ex) { //TODO Log this } } return(new MossResponse { IsValid = false }); }