public void ConnectToServer(string serverIP, short serverDataPort, string username, string password) { m_serverCommand.user = username; // "Admin"; m_serverCommand.password = password; // ""; m_serverCommand.port = (short)(serverDataPort + 1); // 4021; m_serverData.user = m_serverCommand.user; m_serverData.password = m_serverCommand.password; m_serverData.port = serverDataPort; // 4020; IPServices.GetIPAddressTask(serverIP, OnGetDNSComplete); //IPServices.GetIPAddressTask("demovi.com", OnGetDNSComplete); }
void client_getCountryCityByIpCompleted(object sender, IPServices.getCountryCityByIpCompletedEventArgs e) { List<string> resault = e.Result.ToList(); Location ="IP地址:"+resault.First()+"\n"; Location += resault.Last(); logoUpdate(); }
public void GetServerMetadata() { IPServices.TCPTransactionTask(m_serverCommand, VIServices.PacketGetServerClass(m_serverCommand), OnGetServerMetadataComplete); }
public void GetServerVersionAndMetadata() { IPServices.TCPTransactionTask(m_serverCommand, VIServices.PacketGetServerVersion(), OnGetServerVersionAndMetadataComplete); }
public static AsyncRequestObject LiveStream(Socket socket, OnNewLiveFrame NewLiveFrameCallback, CancellationTokenSource cts = null, TaskScheduler ts = null) { AsyncRequestObject aro = new AsyncRequestObject(cts); ts = ts == null?TaskScheduler.FromCurrentSynchronizationContext() : ts; BlockingCollection <LiveCompressedFrame> queueCompressed = new BlockingCollection <LiveCompressedFrame>(1); #region Streaming task aro.task = Task.Factory.StartNew(() => { byte[] bytes = null; HiResTimer t = new HiResTimer(); Int64 t1 = t.Value; Int64 frames = 0; while (!aro.CancellationToken.WaitHandle.WaitOne(0)) { bytes = IPServices.ReceiveOnSocket(socket, aro.CancellationToken, 30000, Marshal.SizeOf(typeof(DATA_FRAME_HEADER))); if (bytes != null && bytes.Length != 0) { // Full header received GCHandle pinnedPacket = GCHandle.Alloc(bytes, GCHandleType.Pinned); DATA_FRAME_HEADER dfh = (DATA_FRAME_HEADER)Marshal.PtrToStructure(pinnedPacket.AddrOfPinnedObject(), typeof(DATA_FRAME_HEADER)); pinnedPacket.Free(); // Get frame bytes = IPServices.ReceiveOnSocket(socket, aro.CancellationToken, 5000, dfh.TotalLength - Marshal.SizeOf(typeof(DATA_FRAME_HEADER))); if (bytes != null && bytes.Length != 0) { //queueCompressed.Add(new LiveCompressedFrame(dfh, bytes), aro.CancellationToken); Debug.Print(dfh.CameraID.ToString() + " " + bytes.Length.ToString()); // add code here to put frame into decoder input queue } else { break; } } else { // Server closed connection? break; } ++frames; if (frames % 100 == 0) { Int64 timeTicks = t.Value - t1; Int64 timeElapseInSeconds = timeTicks / t.Frequency; Debug.Print("Frame rate = {0}", (float)frames / (float)timeElapseInSeconds); } } //fs.Close(); }, aro.CancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default); #endregion return(aro); }
public void GetLive(List <int> cameraIDList) { // TODO: need to somehow pass CudaUtil to VIServices.LiveStream IPServices.TCPRequestTask(m_serverData, VIServices.PacketStartLiveStream(m_serverData, cameraIDList.ToArray()), OnGetLiveConnect); }