private void Client_ReceiveCompleted(object sender, SocketHelper.Events.ReceiveEventArgs args) { if (args.ByteLength > 0) { using (MemoryStream ms = new MemoryStream(args.ReceivedBytes)) { using (BinaryReader br = new BinaryReader(ms)) { int code = br.ReadInt32(); switch ((ParamCode)code) { case ParamCode.TimePeriods: { OnVideoDataInfoReceived(VideoTimePeriodsPacket.Decode(ms)); } break; case ParamCode.LocalDownSource: { OnTreeNodesReceived(LocalVideosInfoPacket.Decode(ms)); } break; case ParamCode.Message: onMessage(MessagePacket.Decode(ms)); break; } } } } }
private void onLocalSourceInfoReceived(LocalVideosInfoPacket obj) { WindowUtil.BeginInvoke(() => { UpdateTimePeriod(obj.TimePeriod.BeginTime, obj.TimePeriod.EndTime); }); }
private void onLocalDownloadPath(string path) { Logger.Default.Trace("获取本地视频信息,Path:{0}", path); LocalVideosInfoPacket packet = FolderManager.GetLocalVideoInfoPacket(path); send(ParamCode.LocalDownSource, LocalVideosInfoPacket.Encode(packet)); }
public void TestLocalVideosInfoPacket() { TimePeriodPacket tpp = new TimePeriodPacket(new DateTime(2016, 7, 25), new DateTime(2016, 7, 25, 17, 0, 0)); VideoTimePeriodsPacket[] vtpps = new VideoTimePeriodsPacket[] { new VideoTimePeriodsPacket(new VideoInfo("id", 2), new TimePeriodPacket[0]), new VideoTimePeriodsPacket(new VideoInfo("id2", 2), new TimePeriodPacket[] { new TimePeriodPacket(new DateTime(2016, 7, 25), new DateTime(2016, 7, 25, 16, 40, 0)) }) }; LocalVideosInfoPacket packet = new LocalVideosInfoPacket(tpp, vtpps); byte[] buffer = LocalVideosInfoPacket.Encode(packet); var packet2 = LocalVideosInfoPacket.Decode(buffer); Assert.AreNotSame(packet, packet2); TimePeriodPacketTest.AssertAreEqual(packet.TimePeriod, packet2.TimePeriod); Assert.AreNotSame(packet.ValidTimePeriods, packet2.ValidTimePeriods); Assert.AreEqual(packet.ValidTimePeriods.Length, packet2.ValidTimePeriods.Length); for (int i = 0; i < packet.ValidTimePeriods.Length; i++) { VideoTimePeriodsPacketTest.AssertAreEqual(packet.ValidTimePeriods[i], packet2.ValidTimePeriods[i]); } }
private void onNodeUpdated(LocalVideosInfoPacket node) { Action <LocalVideosInfoPacket> handler = LocalSourceInfoReceived; if (handler != null) { handler(node); } }
public void UpdateSource(VideoDataSource src) { if (src == null) { throw new ErrorMessageException("视频数据源参数不能为空值。"); } Close(); _src = src; _localVideos = null; SourceValid = true; }
private void onNodeUpdated(LocalVideosInfoPacket packet) { //更新节点树。 if (string.IsNullOrWhiteSpace(SearchContext)) { updateFilteredVideos(); } else { SearchContext = string.Empty; } }
private void OnTreeNodesReceived(LocalVideosInfoPacket lvip) { _localVideos = lvip; Action <LocalVideosInfoPacket> handler = TreeNodesReceived; if (handler != null) { handler(lvip); } foreach (VideoTimePeriodsPacket vtpp in lvip.ValidTimePeriods) { OnVideoDataInfoReceived(vtpp); } }
private void proxy_TreeNodesReceived(LocalVideosInfoPacket obj) { buildNodeRoot(obj.ValidTimePeriods); onNodeUpdated(obj); }
private void InfoManager_NodeUpdated(LocalVideosInfoPacket obj) { onNodeUpdated(obj); }