示例#1
0
        public static void UserRequest()
        {
            var buf = LinksHelper.Generator.Encode(new
            {
                source = LinkModule.Id,
                target = Links.Id,
                path   = "user.request",
            });

            LinkModule.Enqueue(buf);
        }
示例#2
0
        public static void UserRequest()
        {
            var wtr = PacketWriter.Serialize(new
            {
                source = LinkModule.Id,
                target = Links.Id,
                path   = "user.request",
            });
            var buf = wtr.GetBytes();

            LinkModule.Enqueue(buf);
        }
示例#3
0
        /// <summary>
        /// 发送请求监听的用户组
        /// </summary>
        public static void UserGroups()
        {
            var buf = LinksHelper.Generator.Encode(new
            {
                source = LinkModule.Id,
                target = Links.Id,
                path   = "user.group",
                data   = ProfileModule.GroupIds,
            });

            LinkModule.Enqueue(buf);
        }
示例#4
0
        /// <summary>
        /// 发送请求监听的用户组
        /// </summary>
        public static void UserGroups()
        {
            var wtr = PacketWriter.Serialize(new
            {
                source = LinkModule.Id,
                target = Links.Id,
                path   = "user.group",
                data   = ProfileModule.GroupIds,
            });
            var buf = wtr.GetBytes();

            LinkModule.Enqueue(buf);
        }
示例#5
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);
        }
示例#6
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);
        }
示例#7
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);
        }
示例#8
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);
        }
示例#9
0
        /// <summary>
        /// Post feedback message
        /// </summary>
        public static void Notice(int dst, string genre, string arg)
        {
            var buf = LinksHelper.Generator.Encode(new
            {
                source = LinkModule.Id,
                target = dst,
                path   = "msg.notice",
                data   = new
                {
                    type      = genre,
                    parameter = arg,
                },
            });

            LinkModule.Enqueue(buf);
            // you don't have to notice yourself in history module
        }
示例#10
0
        /// <summary>
        /// Post feedback message
        /// </summary>
        public static void Notice(int dst, string genre, string arg)
        {
            var wtr = PacketWriter.Serialize(new
            {
                source = LinkModule.Id,
                target = dst,
                path   = "msg.notice",
                data   = new
                {
                    type      = genre,
                    parameter = arg,
                },
            });
            var buf = wtr.GetBytes();

            LinkModule.Enqueue(buf);
            // you don't have to notice yourself in history module
        }
示例#11
0
        /// <summary>
        /// 向指定用户发送本机用户信息
        /// </summary>
        public static void UserProfile(int dst)
        {
            var pro = ProfileModule.Current;
            var buf = LinksHelper.Generator.Encode(new
            {
                source = LinkModule.Id,
                target = dst,
                path   = "user.profile",
                data   = new
                {
                    id    = ProfileModule.Id,
                    name  = pro.Name,
                    text  = pro.Text,
                    image = ProfileModule.ImageBuffer,
                },
            });

            LinkModule.Enqueue(buf);
        }
示例#12
0
        /// <summary>
        /// 向指定用户发送本机用户信息
        /// </summary>
        public static void UserProfile(int dst)
        {
            var pro = ProfileModule.Current;
            var wtr = PacketWriter.Serialize(new
            {
                source = LinkModule.Id,
                target = dst,
                path   = "user.profile",
                data   = new
                {
                    id    = ProfileModule.Id,
                    name  = pro.Name,
                    text  = pro.Text,
                    image = ProfileModule.ImageBuffer,
                },
            });
            var buf = wtr.GetBytes();

            LinkModule.Enqueue(buf);
        }
示例#13
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);
        }
示例#14
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);
        }