示例#1
0
        public static void Image(int dst, byte[] val)
        {
            var buf = LinksHelper.Generator.Encode(new
            {
                source = LinkModule.Id,
                target = dst,
                path   = "msg.image",
                data   = val,
            });

            LinkModule.Enqueue(buf);
            _ = HistoryModule.Insert(dst, "image", val);
        }
示例#2
0
        public static void Text(int dst, string val)
        {
            var buf = LinksHelper.Generator.Encode(new
            {
                source = LinkModule.Id,
                target = dst,
                path   = "msg.text",
                data   = val,
            });

            LinkModule.Enqueue(buf);
            _ = HistoryModule.Insert(dst, "text", val);
        }
示例#3
0
        public static void Text(int dst, string val)
        {
            var wtr = PacketWriter.Serialize(new
            {
                source = LinkModule.Id,
                target = dst,
                path   = "msg.text",
                data   = val,
            });
            var buf = wtr.GetBytes();

            LinkModule.Enqueue(buf);
            HistoryModule.Insert(dst, "text", val);
        }
示例#4
0
        public static void Image(int dst, byte[] val)
        {
            var wtr = PacketWriter.Serialize(new
            {
                source = LinkModule.Id,
                target = dst,
                path   = "msg.image",
                data   = val,
            });
            var buf = wtr.GetBytes();

            LinkModule.Enqueue(buf);
            HistoryModule.Insert(dst, "image", val);
        }
示例#5
0
        public static void Directory(int dst, string directory)
        {
            var sha = new Share(new DirectoryInfo(directory));

            Application.Current.Dispatcher.Invoke(() => ShareModule.ShareList.Add(sha));
            var buf = LinksHelper.Generator.Encode(new
            {
                source = LinkModule.Id,
                target = dst,
                path   = "share.info",
                data   = new
                {
                    key       = sha._key,
                    type      = "dir",
                    name      = sha.Name,
                    endpoints = LinkModule.GetEndPoints(),
                }
            });

            LinkModule.Enqueue(buf);
            _ = HistoryModule.Insert(dst, "share", sha);
        }
示例#6
0
        /// <summary>
        /// 发送文件信息
        /// </summary>
        public static void File(int dst, string filepath)
        {
            var sha = new Share(new FileInfo(filepath));

            Application.Current.Dispatcher.Invoke(() => ShareModule.ShareList.Add(sha));
            var wtr = PacketWriter.Serialize(new
            {
                source = LinkModule.Id,
                target = dst,
                path   = "share.info",
                data   = new
                {
                    key       = sha._key,
                    type      = "file",
                    name      = sha.Name,
                    length    = sha.Length,
                    endpoints = LinkModule.GetEndPoints(),
                }
            });
            var buf = wtr.GetBytes();

            LinkModule.Enqueue(buf);
            HistoryModule.Insert(dst, "share", sha);
        }