public void StartTracking(IEnumerable <Uri> trackerURIs = null) { lock (_trackers) { if (trackerURIs != null) { _trackers.Clear(); foreach (Uri trackerURI in trackerURIs) { TrackerClient tracker = TrackerClient.Create(trackerURI, _networkID.Number, TrackerClientID.CreateDefaultID(), _customUpdateInterval); tracker.Proxy = _proxy; _trackers.Add(tracker); } } if (_trackerUpdateTimer == null) { if ((_trackers.Count > 0) || (_ipv4DhtNode != null) || (_ipv6DhtNode != null)) { _trackerUpdateTimer = new Timer(TrackerUpdateTimerCallBack, TrackerClientEvent.Started, 1000, Timeout.Infinite); } } } }
private void showPeersToolStripMenuItem_Click(object sender, EventArgs e) { if (lstTrackerInfo.SelectedItems.Count > 0) { TrackerClient tracker = lstTrackerInfo.SelectedItems[0].Tag as TrackerClient; IEnumerable <IPEndPoint> peerEPs; if (tracker == null) { peerEPs = _chat.DhtGetPeers(); } else { peerEPs = tracker.Peers; } string peers = ""; foreach (IPEndPoint peerEP in peerEPs) { peers += peerEP.ToString() + "\r\n"; } if (peers == "") { MessageBox.Show("No peer returned by the tracker.", "No Peer Available", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(peers, "Peers List", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void timer_Tick(object sender, EventArgs e) { lock (lstTrackerInfo.Items) { bool tracking = _chat.IsTrackerRunning; foreach (ListViewItem item in lstTrackerInfo.Items) { if (tracking) { TrackerClient tracker = item.Tag as TrackerClient; TimeSpan updateIn; Exception lastException; int peerCount; if (tracker == null) { updateIn = _chat.DhtNextUpdateIn(); lastException = _chat.DhtLastException(); peerCount = _chat.DhtGetTotalPeers(); } else { updateIn = tracker.NextUpdateIn(); lastException = tracker.LastException; peerCount = tracker.Peers.Count; } string strUpdateIn = "updating..."; if (updateIn.TotalSeconds > 1) { strUpdateIn = ""; if (updateIn.Hours > 0) { strUpdateIn = updateIn.Hours + "h "; } if (updateIn.Minutes > 0) { strUpdateIn += updateIn.Minutes + "m "; } strUpdateIn += updateIn.Seconds + "s"; } item.SubItems[1].Text = lastException == null ? "working" : "[" + tracker.RetriesDone + "] " + lastException.Message; item.SubItems[2].Text = strUpdateIn; item.SubItems[3].Text = peerCount.ToString(); } else { item.SubItems[1].Text = "not tracking"; item.SubItems[2].Text = ""; item.SubItems[3].Text = ""; } } } }
private void addTrackerToolStripMenuItem_Click(object sender, EventArgs e) { using (frmAddTracker frm = new frmAddTracker()) { if (frm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { List <Uri> uriList = frm.TrackerUriList; foreach (Uri uri in uriList) { TrackerClient tracker = _chat.AddTracker(uri); if (tracker != null) { ListViewItem item = new ListViewItem(tracker.TrackerUri.AbsoluteUri); item.Tag = tracker; item.SubItems.Add(""); item.SubItems.Add("updating..."); item.SubItems.Add("0"); lock (lstTrackerInfo.Items) { lstTrackerInfo.Items.Add(item); } } } } } }
private void _timer_Tick(object sender, EventArgs e) { lock (lstTrackerInfo.Items) { foreach (ListViewItem item in lstTrackerInfo.Items) { TrackerClient tracker = item.Tag as TrackerClient; string strUpdateIn = "updating..."; TimeSpan updateIn = tracker.NextUpdateIn(); if (updateIn.TotalSeconds > 1) { strUpdateIn = ""; if (updateIn.Hours > 0) { strUpdateIn = updateIn.Hours + "h "; } if (updateIn.Minutes > 0) { strUpdateIn += updateIn.Minutes + "m "; } strUpdateIn += updateIn.Seconds + "s"; } item.SubItems[1].Text = tracker.LastException == null ? "working" : tracker.LastException.Message; item.SubItems[2].Text = strUpdateIn; item.SubItems[3].Text = tracker.Peers.Count.ToString(); } } }
private void copyAllTrackersToolStripMenuItem_Click(object sender, EventArgs e) { string trackers = ""; lock (lstTrackerInfo.Items) { foreach (ListViewItem item in lstTrackerInfo.Items) { TrackerClient tracker = item.Tag as TrackerClient; trackers += tracker.TrackerUri.AbsoluteUri + "\r\n"; } } if (trackers != "") { try { Clipboard.Clear(); Clipboard.SetText(trackers); } catch { } } }
public void AddTracker(IEnumerable <Uri> trackerURIs) { lock (_trackers) { foreach (Uri trackerURI in trackerURIs) { bool trackerExists = false; foreach (TrackerClient tracker in _trackers) { if (tracker.TrackerUri.Equals(trackerURI)) { trackerExists = true; break; } } if (!trackerExists) { TrackerClient tracker = TrackerClient.Create(trackerURI, _networkID.Number, TrackerClientID.CreateDefaultID(), _customUpdateInterval); tracker.Proxy = _proxy; _trackers.Add(tracker); } } } }
public void RemoveTracker(TrackerClient tracker) { lock (_trackers) { _trackers.Remove(tracker); } }
private void UpdateTrackerAsync(object state) { object[] parameters = state as object[]; TrackerClient tracker = parameters[0] as TrackerClient; TrackerClientEvent @event = (TrackerClientEvent)parameters[1]; IPEndPoint localEP = parameters[2] as IPEndPoint; try { tracker.Update(@event, localEP); switch (@event) { case TrackerClientEvent.Started: case TrackerClientEvent.Completed: case TrackerClientEvent.None: if (_lookupOnly) { tracker.Update(TrackerClientEvent.Stopped, localEP); } if (tracker.Peers.Count > 0) { if (_ipv4DhtNode != null) { _ipv4DhtNode.AddNode(tracker.Peers); } if (_ipv6DhtNode != null) { _ipv6DhtNode.AddNode(tracker.Peers); } DiscoveredPeers?.Invoke(this, tracker.Peers); } break; } tracker.CustomUpdateInterval = _customUpdateInterval; } catch { if (tracker.RetriesDone < TRACKER_MAX_RETRIES) { tracker.CustomUpdateInterval = TRACKER_RETRY_UPDATE_INTERVAL_SECONDS; } else { tracker.CustomUpdateInterval = TRACKER_FAILED_UPDATE_INTERVAL_SECONDS; } } }
private void updateTrackerToolStripMenuItem_Click(object sender, EventArgs e) { lock (lstTrackerInfo.Items) { foreach (ListViewItem item in lstTrackerInfo.SelectedItems) { TrackerClient tracker = item.Tag as TrackerClient; tracker.ScheduleUpdateNow(); } } }
public MainForm() { InitializeComponent(); var appConfig = AppConfig.Load(); _textBoxTrackerClientLogger = new TextBoxTrackerClientLogger(textBoxLogs); LogConfiguration(appConfig); _trackerClient = new TrackerClient(_textBoxTrackerClientLogger, appConfig.TrackerClientConfig); _trackerClient.TrackerDataReceived += TrackerDataReceived; }
static void Main(string[] args) { var files = new[] { "1.jpg", "2.jpg", "3.jpg", }; ClientGlobal.InitFromFile("fdfs_client.json"); Console.WriteLine(ClientGlobal.configInfo()); var trackerClient = new TrackerClient(); var trackerServer = trackerClient.getConnection(); var storageClient = new StorageClient(trackerServer, null); var fileIds = new List <string[]>(); Console.WriteLine($"Total files to be upload: {files.Length}"); foreach (var file in files) { var metaData = new NameValueCollection { ["filename"] = file }; var result = storageClient.upload_file(file, null, metaData); if (result != null) { fileIds.Add(result); var fileId = string.Join("/", result); Console.WriteLine($"Upload success. file: {file}, file id: {fileId}"); } else { Console.WriteLine($"Failed to upload file: {file}"); } } foreach (var fileId in fileIds) { var fileData = storageClient.download_file(fileId[0], fileId[1]); using (var fs = System.IO.File.Create(System.IO.Path.GetFileName(fileId[1]))) { fs.Write(fileData, 0, fileData.Length); } } Console.ReadLine(); }
private void removeTrackerToolStripMenuItem_Click(object sender, EventArgs e) { lock (lstTrackerInfo.Items) { foreach (ListViewItem item in lstTrackerInfo.SelectedItems) { TrackerClient tracker = item.Tag as TrackerClient; _chat.RemoveTracker(tracker); lstTrackerInfo.Items.Remove(item); } } }
private void UpdateTrackerAsync(object state) { object[] parameters = state as object[]; TrackerClient tracker = parameters[0] as TrackerClient; TrackerClientEvent @event = (TrackerClientEvent)parameters[1]; IPEndPoint localEP = parameters[2] as IPEndPoint; try { tracker.Update(@event, localEP); _network.MakeConnection(tracker.Peers); } catch { } }
public static void Main(string[] args) { Options options = Argument.Parse <Options>(args); if (options.IsValid()) { using (TrackerClient client = new TrackerClient()) { TrackerSession session = client.ConnectAsync(options.Tracker).Result; session.Announce(options.Hashes.Select(FileHash.Parse).ToArray()); while (true) { Console.WriteLine(session.NextAsync().Result); } } } }
private void StartTracking(Uri[] trackerURIs) { _manager.StartLocalAnnouncement(_network.NetworkID); lock (_trackers) { _trackers.Clear(); foreach (Uri trackerURI in trackerURIs) { _trackers.Add(TrackerClient.Create(trackerURI, _network.NetworkID.ID, TrackerClientID.CreateDefaultID())); } } if (_trackerUpdateTimer == null) { _trackerUpdateTimer = new Timer(UpdateTracker, TrackerClientEvent.Started, 1000, Timeout.Infinite); } }
public TrackerClient AddTracker(Uri trackerURI) { lock (_trackers) { foreach (TrackerClient tracker in _trackers) { if (tracker.TrackerUri.Equals(trackerURI)) { return(null); } } TrackerClient newTracker = TrackerClient.Create(trackerURI, _network.NetworkID.ID, TrackerClientID.CreateDefaultID()); _trackers.Add(newTracker); return(newTracker); } }
public void Start() { var stopwatch = new Stopwatch(); stopwatch.Start(); Loggers.Current.Log(LogLevel.Info, $"Starting TwometerVR v{Version}"); Loggers.Current.Log(LogLevel.Debug, "Opening video stream"); var videoConfig = configProvider.VideoSourceConfig; videoSource = VideoSourceFactory.Create(videoConfig.VideoSourceType, videoConfig.VideoSourceIndex); videoSource.Width = videoConfig.FrameWidth; videoSource.Height = videoConfig.FrameHeight; videoSource.Framerate = videoConfig.Framerate; videoSource.Open(); Loggers.Current.Log(LogLevel.Debug, "Initializing tracking engine"); trackingEngine = new TrackingEngine(trackerManager, configProvider, videoSource); Loggers.Current.Log(LogLevel.Debug, "Setting up network"); discoveryClient = new DiscoveryClient(); driverClient = new DriverClient(trackerManager); trackerClient = new TrackerClient(trackerManager); watchdog = new TrackerWatchdog(trackerManager, configProvider); Loggers.Current.Log(LogLevel.Debug, "Initializing update timer"); updateTimer = new Timer(Update, null, 0, 1 / configProvider.UserConfig.Input.RefreshRate); Loggers.Current.Log(LogLevel.Debug, "Starting video procecssing thread"); videoThread = new Thread(VideoLoop); videoThread.Start(); stopwatch.Stop(); Loggers.Current.Log(LogLevel.Info, $"Done after {stopwatch.Elapsed}"); }
public TrackerClient AddTracker(Uri trackerURI) { lock (_trackers) { foreach (TrackerClient tracker in _trackers) { if (tracker.TrackerUri.Equals(trackerURI)) { return(null); } } { TrackerClient tracker = TrackerClient.Create(trackerURI, _networkID.Number, TrackerClientID.CreateDefaultID(), _customUpdateInterval); tracker.Proxy = _proxy; _trackers.Add(tracker); return(tracker); } } }
public static void Run(string[] args) { if (args.Length < 1) { Console.WriteLine("Error: Must have 1 parameter: config filename"); return; } try { ClientGlobal.init(args[0]); TrackerClient tc = new TrackerClient(); TrackerServer tracker = tc.getConnection(); if (tracker == null) { return; } int count = 0; StructGroupStat[] groupStats = tc.listGroups(tracker); if (groupStats == null) { Console.WriteLine(""); Console.WriteLine("ERROR! list groups error, error no: " + tc.ErrorCode); Console.WriteLine(""); return; } Console.WriteLine("group count: " + groupStats.Length); foreach (StructGroupStat groupStat in groupStats) { count++; Console.WriteLine("Group " + count + ":"); Console.WriteLine("group name = " + groupStat.GroupName); Console.WriteLine("disk total space = " + groupStat.TotalMB + "MB"); Console.WriteLine("disk free space = " + groupStat.FreeMB + " MB"); Console.WriteLine("trunk free space = " + groupStat.TrunkFreeMB + " MB"); Console.WriteLine("storage server count = " + groupStat.StorageCount); Console.WriteLine("active server count = " + groupStat.ActiveCount); Console.WriteLine("storage server port = " + groupStat.StoragePort); Console.WriteLine("storage HTTP port = " + groupStat.StorageHttpPort); Console.WriteLine("store path count = " + groupStat.StorePathCount); Console.WriteLine("subdir count per path = " + groupStat.SubdirCountPerPath); Console.WriteLine("current write server index = " + groupStat.CurrentWriteServer); Console.WriteLine("current trunk file id = " + groupStat.CurrentTrunkFileId); StructStorageStat[] storageStats = tc.listStorages(tracker, groupStat.GroupName); if (storageStats == null) { Console.WriteLine(""); Console.WriteLine("ERROR! list storage error, error no: " + tc.ErrorCode); Console.WriteLine(""); break; } int stroageCount = 0; foreach (StructStorageStat storageStat in storageStats) { stroageCount++; Console.WriteLine("\tStorage " + stroageCount + ":"); Console.WriteLine("\t\tstorage id = " + storageStat.Id); Console.WriteLine("\t\tip_addr = " + storageStat.IpAddr + " " + ProtoCommon.getStorageStatusCaption(storageStat.Status)); Console.WriteLine("\t\thttp domain = " + storageStat.DomainName); Console.WriteLine("\t\tversion = " + storageStat.Version); Console.WriteLine("\t\tjoin time = " + storageStat.JoinTime.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("\t\tup time = " + storageStat.UpTime.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("\t\ttotal storage = " + storageStat.TotalMB + "MB"); Console.WriteLine("\t\tfree storage = " + storageStat.FreeMB + "MB"); Console.WriteLine("\t\tupload priority = " + storageStat.UploadPriority); Console.WriteLine("\t\tstore_path_count = " + storageStat.StorePathCount); Console.WriteLine("\t\tsubdir_count_per_path = " + storageStat.SubdirCountPerPath); Console.WriteLine("\t\tstorage_port = " + storageStat.StoragePort); Console.WriteLine("\t\tstorage_http_port = " + storageStat.StorageHttpPort); Console.WriteLine("\t\tcurrent_write_path = " + storageStat.CurrentWritePath); Console.WriteLine("\t\tsource ip_addr = " + storageStat.SrcIpAddr); Console.WriteLine("\t\tif_trunk_server = " + storageStat.IfTrunkServer); Console.WriteLine("\t\tconntion.alloc_count = " + storageStat.ConnectionAllocCount); Console.WriteLine("\t\tconntion.current_count = " + storageStat.ConnectionCurrentCount); Console.WriteLine("\t\tconntion.max_count = " + storageStat.ConnectionMaxCount); Console.WriteLine("\t\ttotal_upload_count = " + storageStat.TotalUploadCount); Console.WriteLine("\t\tsuccess_upload_count = " + storageStat.SuccessUploadCount); Console.WriteLine("\t\ttotal_append_count = " + storageStat.TotalAppendCount); Console.WriteLine("\t\tsuccess_append_count = " + storageStat.SuccessAppendCount); Console.WriteLine("\t\ttotal_modify_count = " + storageStat.TotalModifyCount); Console.WriteLine("\t\tsuccess_modify_count = " + storageStat.SuccessModifyCount); Console.WriteLine("\t\ttotal_truncate_count = " + storageStat.TotalTruncateCount); Console.WriteLine("\t\tsuccess_truncate_count = " + storageStat.SuccessTruncateCount); Console.WriteLine("\t\ttotal_set_meta_count = " + storageStat.TotalSetMetaCount); Console.WriteLine("\t\tsuccess_set_meta_count = " + storageStat.SuccessSetMetaCount); Console.WriteLine("\t\ttotal_delete_count = " + storageStat.TotalDeleteCount); Console.WriteLine("\t\tsuccess_delete_count = " + storageStat.SuccessDeleteCount); Console.WriteLine("\t\ttotal_download_count = " + storageStat.TotalDownloadCount); Console.WriteLine("\t\tsuccess_download_count = " + storageStat.SuccessDownloadCount); Console.WriteLine("\t\ttotal_get_meta_count = " + storageStat.TotalGetMetaCount); Console.WriteLine("\t\tsuccess_get_meta_count = " + storageStat.SuccessGetMetaCount); Console.WriteLine("\t\ttotal_create_link_count = " + storageStat.TotalCreateLinkCount); Console.WriteLine("\t\tsuccess_create_link_count = " + storageStat.SuccessCreateLinkCount); Console.WriteLine("\t\ttotal_delete_link_count = " + storageStat.TotalDeleteLinkCount); Console.WriteLine("\t\tsuccess_delete_link_count = " + storageStat.SuccessDeleteLinkCount); Console.WriteLine("\t\ttotal_upload_bytes = " + storageStat.TotalUploadBytes); Console.WriteLine("\t\tsuccess_upload_bytes = " + storageStat.SuccessUploadBytes); Console.WriteLine("\t\ttotal_append_bytes = " + storageStat.TotalAppendBytes); Console.WriteLine("\t\tsuccess_append_bytes = " + storageStat.SuccessAppendBytes); Console.WriteLine("\t\ttotal_modify_bytes = " + storageStat.TotalModifyBytes); Console.WriteLine("\t\tsuccess_modify_bytes = " + storageStat.SuccessModifyBytes); Console.WriteLine("\t\ttotal_download_bytes = " + storageStat.TotalDownloadloadBytes); Console.WriteLine("\t\tsuccess_download_bytes = " + storageStat.SuccessDownloadloadBytes); Console.WriteLine("\t\ttotal_sync_in_bytes = " + storageStat.TotalSyncInBytes); Console.WriteLine("\t\tsuccess_sync_in_bytes = " + storageStat.SuccessSyncInBytes); Console.WriteLine("\t\ttotal_sync_out_bytes = " + storageStat.TotalSyncOutBytes); Console.WriteLine("\t\tsuccess_sync_out_bytes = " + storageStat.SuccessSyncOutBytes); Console.WriteLine("\t\ttotal_file_open_count = " + storageStat.TotalFileOpenCount); Console.WriteLine("\t\tsuccess_file_open_count = " + storageStat.SuccessFileOpenCount); Console.WriteLine("\t\ttotal_file_read_count = " + storageStat.TotalFileReadCount); Console.WriteLine("\t\tsuccess_file_read_count = " + storageStat.SuccessFileReadCount); Console.WriteLine("\t\ttotal_file_write_count = " + storageStat.TotalFileWriteCount); Console.WriteLine("\t\tsuccess_file_write_count = " + storageStat.SuccessFileWriteCount); Console.WriteLine("\t\tlast_heart_beat_time = " + storageStat.LastHeartBeatTime.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("\t\tlast_source_update = " + storageStat.LastSourceUpdate.ToString("yyyy-MM-dd HH:mm:ss")); Console.WriteLine("\t\tlast_sync_update = " + storageStat.LastSyncUpdate.ToString("yyyy-MM-dd HH:mm:ss")); //Console.WriteLine("\t\tlast_synced_timestamp = " + storageStat.LastSyncedTimestamp.ToString("yyyy-MM-dd HH:mm:ss") + getSyncedDelayString(storageStats, storageStat)); } } tracker.close(); Console.Read(); } catch (Exception ex) { Console.WriteLine(ex); } }
public FdfsClient() { _trackerClient = new TrackerClient(); }
public static void Run(string[] args) { if (args.Length < 2) { Console.WriteLine("Error: Must have 2 parameters, one is config filename, " + "the other is the local filename to upload"); return; } string conf_filename = args[0]; string local_filename = args[1]; try { ClientGlobal.init(conf_filename); long startTime; ServerInfo[] servers; TrackerClient tracker = new TrackerClient(); TrackerServer trackerServer = tracker.getConnection(); StorageServer storageServer = null; StorageClientEx client = new StorageClientEx(trackerServer, storageServer); byte[] file_buff; NameValuePair[] meta_list; string group_name; string appender_file_id; string file_ext_name; int errno; meta_list = new NameValuePair[4]; meta_list[0] = new NameValuePair("width", "800"); meta_list[1] = new NameValuePair("heigth", "600"); meta_list[2] = new NameValuePair("bgcolor", "#FFFFFF"); meta_list[3] = new NameValuePair("author", "Mike"); file_buff = Encoding.GetEncoding(ClientGlobal.g_charset).GetBytes("this is a test"); Console.WriteLine("file length: " + file_buff.Length); group_name = null; StorageServer[] storageServers = tracker.getStoreStorages(trackerServer, group_name); if (storageServers == null) { Console.WriteLine("get store storage servers fail, error code: " + tracker.ErrorCode); } else { Console.WriteLine("store storage servers count: " + storageServers.Length); for (int k = 0; k < storageServers.Length; k++) { Console.WriteLine((k + 1) + ". " + storageServers[k].InetSockAddr.Address + ":" + storageServers[k].InetSockAddr.Port); } Console.WriteLine(""); } Stopwatch sw = new Stopwatch(); sw.Start(); appender_file_id = client.upload_appender_file1(file_buff, "txt", meta_list); sw.Stop(); Console.WriteLine("upload_appender_file1 time used: " + sw.ElapsedMilliseconds + " ms"); /* * group_name = ""; * appender_file_id = client.upload_appender_file1(group_name, file_buff, "txt", meta_list); */ if (appender_file_id == null) { Console.WriteLine("upload file fail, error code: " + client.ErrorCode); return; } else { Console.WriteLine(client.get_file_info1(appender_file_id)); servers = tracker.getFetchStorages1(trackerServer, appender_file_id); if (servers == null) { Console.WriteLine("get storage servers fail, error code: " + tracker.ErrorCode); } else { Console.WriteLine("storage servers count: " + servers.Length); for (int k = 0; k < servers.Length; k++) { Console.WriteLine((k + 1) + ". " + servers[k].Ip_Addr + ":" + servers[k].Port); } Console.WriteLine(""); } meta_list = new NameValuePair[4]; meta_list[0] = new NameValuePair("width", "1024"); meta_list[1] = new NameValuePair("heigth", "768"); meta_list[2] = new NameValuePair("bgcolor", "#000000"); meta_list[3] = new NameValuePair("title", "Untitle"); sw.Restart(); errno = client.set_metadata1(appender_file_id, meta_list, ProtoCommon.STORAGE_SET_METADATA_FLAG_MERGE); sw.Stop(); Console.WriteLine("set_metadata time used: " + sw.ElapsedMilliseconds + " ms"); if (errno == 0) { Console.WriteLine("set_metadata success"); } else { Console.WriteLine("set_metadata fail, error no: " + errno); } meta_list = client.get_metadata1(appender_file_id); if (meta_list != null) { for (int i = 0; i < meta_list.Length; i++) { Console.WriteLine(meta_list[i]._Name + " " + meta_list[i]._Value); } } sw.Restart(); file_buff = client.download_file1(appender_file_id); sw.Stop(); Console.WriteLine("download_file time used: " + sw.ElapsedMilliseconds + " ms"); if (file_buff != null) { Console.WriteLine("file length:" + file_buff.Length); Console.WriteLine(Encoding.GetEncoding(ClientGlobal.g_charset).GetString(file_buff)); } file_buff = Encoding.GetEncoding(ClientGlobal.g_charset).GetBytes("this is a slave buff"); file_ext_name = "txt"; sw.Restart(); errno = client.append_file1(appender_file_id, file_buff); sw.Stop(); Console.WriteLine("append_file time used: " + sw.ElapsedMilliseconds + " ms"); if (errno == 0) { Console.WriteLine(client.get_file_info1(appender_file_id)); } else { Console.WriteLine("append file fail, error no: " + errno); } sw.Restart(); errno = client.delete_file1(appender_file_id); sw.Stop(); Console.WriteLine("delete_file time used: " + sw.ElapsedMilliseconds + " ms"); if (errno == 0) { Console.WriteLine("Delete file success"); } else { Console.WriteLine("Delete file fail, error no: " + errno); } } appender_file_id = client.upload_appender_file1(local_filename, null, meta_list); if (appender_file_id != null) { int ts; string token; string file_url; IPEndPoint inetSockAddr; inetSockAddr = trackerServer.InetSockAddr; file_url = "http://" + inetSockAddr.Address; if (ClientGlobal.g_tracker_http_port != 80) { file_url += ":" + ClientGlobal.g_tracker_http_port; } file_url += "/" + appender_file_id; if (ClientGlobal.g_anti_steal_token) { ts = (int)ProtoCommon.DateTimeToUnixTimestamp(DateTime.Now); token = ProtoCommon.getToken(appender_file_id, ts, ClientGlobal.g_secret_key); file_url += "?token=" + token + "&ts=" + ts; } Console.WriteLine(client.get_file_info1(appender_file_id)); Console.WriteLine("file url: " + file_url); errno = client.download_file1(appender_file_id, 0, 0, "c:\\" + appender_file_id.Replace("/", "_")); if (errno == 0) { Console.WriteLine("Download file success"); } else { Console.WriteLine("Download file fail, error no: " + errno); } errno = client.download_file1(appender_file_id, 0, 0, new DownloadFileWriter("c:\\" + appender_file_id.Replace("/", "-"))); if (errno == 0) { Console.WriteLine("Download file success"); } else { Console.WriteLine("Download file fail, error no: " + errno); } file_ext_name = null; sw.Restart(); errno = client.append_file1(appender_file_id, local_filename); sw.Stop(); Console.WriteLine("append_file time used: " + sw.ElapsedMilliseconds + " ms"); if (errno == 0) { Console.WriteLine(client.get_file_info1(appender_file_id)); } else { Console.WriteLine("append file fail, error no: " + errno); } } System.IO.FileInfo f; f = new System.IO.FileInfo(local_filename); file_ext_name = Path.GetExtension(local_filename).Trim('.'); appender_file_id = client.upload_appender_file1(null, f.Length, new UploadLocalFileSender(local_filename), file_ext_name, meta_list); if (appender_file_id != null) { Console.WriteLine(client.get_file_info1(appender_file_id)); sw.Restart(); errno = client.append_file1(appender_file_id, f.Length, new UploadLocalFileSender(local_filename)); sw.Stop(); Console.WriteLine("append_file time used: " + sw.ElapsedMilliseconds + " ms"); if (errno == 0) { Console.WriteLine(client.get_file_info1(appender_file_id)); } else { Console.WriteLine("append file fail, error no: " + errno); } sw.Restart(); errno = client.modify_file1(appender_file_id, 0, f.Length, new UploadLocalFileSender(local_filename)); sw.Stop(); Console.WriteLine("modify_file time used: " + sw.ElapsedMilliseconds + " ms"); if (errno == 0) { Console.WriteLine(client.get_file_info1(appender_file_id)); } else { Console.WriteLine("modify file fail, error no: " + errno); } sw.Restart(); errno = client.truncate_file1(appender_file_id, 0); sw.Stop(); Console.WriteLine("truncate_file time used: " + sw.ElapsedMilliseconds + " ms"); if (errno == 0) { Console.WriteLine(client.get_file_info1(appender_file_id)); } else { Console.WriteLine("truncate file fail, error no: " + errno); } } else { Console.WriteLine("Upload file fail, error no: " + errno); } storageServer = tracker.getFetchStorage1(trackerServer, appender_file_id); if (storageServer == null) { Console.WriteLine("getFetchStorage fail, errno code: " + tracker.ErrorCode); return; } /* for test only */ Console.WriteLine("active test to storage server: " + ProtoCommon.activeTest(storageServer.getSocket())); storageServer.close(); /* for test only */ Console.WriteLine("active test to tracker server: " + ProtoCommon.activeTest(trackerServer.getSocket())); trackerServer.close(); } catch (Exception ex) { } }
void Start() { tracker = GameObject.Find("TrackerClientGO").GetComponent <TrackerClient>(); shapes = new List <Shape>(); }