Esempio n. 1
0
        static void Main(String[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api地址方式
            //RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);

            Distribute distribute = rongCloud.Chatroom.distribute;

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/distribute.html#stop
             *
             * 聊天室消息停止分发
             *
             */
            ChatroomModel chatroomModel = new ChatroomModel()
            {
                Id = "d7ec7a8b8d8546c98b0973417209a548"
            };
            ResponseResult result = distribute.Stop(chatroomModel);

            Console.WriteLine("stopDistributionMessage:  " + result.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/distribute.html#resume
             *
             * 聊天室消息恢复分发方法(每秒钟限 100 次)
             */
            ResponseResult resumeResult = distribute.Resume(chatroomModel);

            Console.WriteLine("resumeDistributionMessage:  " + resumeResult.ToString());
            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main(String[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api 地址方式
            // RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);
            User User = rongCloud.user;

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/user/user.html#register
             *
             * 注册用户,生成用户在融云的唯一身份标识 Token
             */
            UserModel user = new UserModel
            {
                Id       = "注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token注册用户,生成用户在融云的唯一身份标识 Token",
                Name     = "username",
                Portrait = "http://www.rongcloud.cn/images/logo.png"
            };

            TokenResult result = User.Register(user);

            Console.WriteLine("getToken:  " + result.ToString());

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/user/user.html#refresh
             *
             * 刷新用户信息方法
             */
            Result refreshResult = User.Update(user);

            Console.WriteLine("refresh:  " + refreshResult.ToString());

            Console.ReadLine();
        }
Esempio n. 3
0
        static async Task Main(string[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api地址方式
            //RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);

            Ban ban = rongCloud.Chatroom.ban;

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/ban.html#add
             * 添加聊天室全局禁言
             * */
            ChatroomMember[] members =
            {
                new ChatroomMember()
                {
                    Id = "qawr34h"
                },
                new ChatroomMember()
                {
                    Id = "qawr35h"
                }
            };
            ChatroomModel chatroom = new ChatroomModel()
            {
                Members = members,
                Minute  = 5
            };

            ResponseResult result = await ban.Add(chatroom);

            Console.WriteLine("addGagUser:  "******"ListGagUser:  "******"removeBanUser:  " + removeResult);
            Console.ReadLine();
        }
Esempio n. 4
0
        public static async Task Main(string[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);

            /**
             *
             * API 文档:
             * https://www.rongcloud.cn/docs/push_service.html#broadcast
             *
             * 广播消息
             *
             **/
            BroadcastModel broadcast = new BroadcastModel();

            broadcast.SetFromuserid("fromuserid");
            broadcast.SetPlatform(new string[] { "ios", "android" });
            Audience audience = new Audience();

            audience.SetUserid(new string[] { "userid1", "userid2" });
            broadcast.SetAudience(audience);
            Message message = new Message();

            message.SetContent("this is message");
            message.SetObjectName("RC:TxtMsg");
            broadcast.SetMessage(message);
            Notification notification = new Notification();

            notification.SetAlert("this is broadcast");
            broadcast.SetNotification(notification);
            PushResult result = await rongCloud.Broadcast.Send(broadcast);

            Console.WriteLine("broadcast: " + result);


            /**
             *
             * API 文档:
             * https://www.rongcloud.cn/docs/push_service.html#push
             *
             * 推送消息
             *
             **/
            PushModel pushmodel = new PushModel();

            pushmodel.SetPlatform(new string[] { "ios", "android" });
            audience = new Audience();
            audience.SetUserid(new string[] { "userid1", "userid2" });
            pushmodel.SetAudience(audience);
            notification = new Notification();
            notification.SetAlert("this is push");
            pushmodel.SetNotification(notification);
            result = await rongCloud.Push.Send(pushmodel);

            Console.WriteLine("push: " + result);

            Console.ReadLine();
        }
Esempio n. 5
0
        static void Main(String[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api 地址方式
            // RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);

            Blacklist blackList = rongCloud.User.blackList;

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/user/black.html#add
             * 添加用户到黑名单方法
             */
            UserModel blackUser = new UserModel()
            {
                Id = "hdsjGB88"
            };

            UserModel[] blacklist = { blackUser };
            UserModel   user      = new UserModel()
            {
                Id        = "hdsjGB89",
                Blacklist = blacklist
            }
            ;


            Result userAddBlacklistResult = (Result)blackList.Add(user);

            Console.WriteLine("addBlacklist:  " + userAddBlacklistResult.ToString());

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/user/black.html#getList
             * 获取某用户的黑名单列表方法
             */
            UserModel user2 = new UserModel()
            {
                Id = "hdsjGB89"
            };

            BlackListResult result = blackList.GetList(user2);

            Console.WriteLine("query blacklist:  " + result.ToString());

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/user/black.html#remove
             * 从黑名单中移除用户方法
             */
            Result removeResult = blackList.Remove(user);

            Console.WriteLine("remove blacklist:  " + removeResult.ToString());

            Console.ReadLine();
        }
Esempio n. 6
0
        static void main(String[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api地址方式
            //RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);

            Whitelist whitelist = rongCloud.Chatroom.whiteList;

            /**
             * API: 文档http://www.rongcloud.cn/docs/server_sdk_api/chatroom/whitelist/user.html#add
             * 添加聊天室用户白名单
             * */
            ChatroomMember[] members =
            {
                new ChatroomMember()
                {
                    Id = "qawr34h"
                }, new ChatroomMember()
                {
                    Id = "qawr35h"
                }
            };
            ChatroomModel chatroom = new ChatroomModel()
            {
                Id      = "d7ec7a8b8d8546c98b0973417209a548",
                Members = members
            };

            ResponseResult addResult = whitelist.User.Add(chatroom);

            Console.WriteLine("add whitelist:  " + addResult.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/whitelist/user.html#getList
             * 获取聊天室用户白名单
             * */

            WhiteListResult getResult = whitelist.User.GetList(chatroom);

            Console.WriteLine("get whitelist:  " + getResult.ToString());


            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/whitelist/user.html#remove
             * 删除聊天室用户白名单
             * */

            ResponseResult removeResult = whitelist.User.Remove(chatroom);

            Console.WriteLine("remove whitelist:  " + removeResult.ToString());

            Console.ReadLine();
        }
Esempio n. 7
0
        public static async Task Main(string[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api 地址方式
            // RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);
            User User = rongCloud.User;

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/user/user.html#register
             *
             * 注册用户,生成用户在融云的唯一身份标识 Token
             */
            UserModel user = new UserModel
            {
                Id       = "注册用户,生成用户在融云的唯一身份标识",
                Name     = "username",
                Portrait = "http://www.rongcloud.cn/images/logo.png"
            };

            TokenResult result = await User.Register(user);

            Console.WriteLine("getToken:  " + result);

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/user/user.html#refresh
             *
             * 刷新用户信息方法
             */
            Result refreshResult = await User.Update(user);

            Console.WriteLine("refresh:  " + refreshResult);

            /**
             * 用户标签
             */
            Tag            tag      = User.tag;
            TagModel       tagModel = new TagModel("111", new[] { "一级" });
            ResponseResult re       = await tag.Set(tagModel);

            Console.WriteLine(re);

            Console.WriteLine(tag.BatchSet(new TagModel(new[] { "111", "222" }, new[] { "二级", "三级", "四季" })));

            TagListResult tags = (TagListResult)await tag.Get(new[] { "111" });

            Console.WriteLine(tags);

            Console.ReadLine();
        }
Esempio n. 8
0
        /**
         * 自定义api地址
         * */
        //private static readonly String api = "http://api.cn.ronghub.com";

        static void Main(String[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api 地址方式
            // RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);

            Block block = rongCloud.User.block;

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/user/block.html#add
             * 解除用户封禁
             *
             */
            UserModel user = new UserModel()
            {
                Id     = "hkjo09h",
                Minute = 1000
            };

            Result addBlockResult = (ResponseResult)block.Add(user);

            Console.WriteLine("userAddBlock:  " + addBlockResult.ToString());

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/user/block.html#remove
             * 解除用户封禁
             *
             */
            ResponseResult unBlockResult = (ResponseResult)block.Remove(user.Id);

            Console.WriteLine("unBlock:  " + unBlockResult.ToString());

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/user/block.html#getList
             * 获取被封禁用户
             *
             */
            BlockUserResult blockResult = (BlockUserResult)block.GetList();

            Console.Write("queryBlock:  " + blockResult.ToString());

            Console.ReadLine();
        }
        static void Main(String[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api地址方式
            //RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);

            Keepalive keepalive = rongCloud.chatroom.keepalive;

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/keepalive.html#add
             *
             * 添加保活聊天室
             *
             **/
            ChatroomModel chatroom = new ChatroomModel()
            {
                Id = "d7ec7a8b8d8546c98b0973417209a548"
            };
            ResponseResult addResult = keepalive.Add(chatroom);

            Console.WriteLine("add keepalive result" + addResult.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/keepalive.html#remove
             *
             * 删除保活聊天室
             *
             **/
            ResponseResult removeResult = keepalive.Remove(chatroom);

            Console.WriteLine("keepalive remove" + removeResult.ToString());

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/keepalive.html#getList
             *
             * 获取保活聊天室
             *
             **/
            ChatroomKeepaliveResult result = keepalive.GetList();

            Console.WriteLine("keepalive getList" + result.ToString());
            Console.ReadLine();
        }
Esempio n. 10
0
        static void Main(String[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api地址方式
            //RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);

            Demotion demotion = rongCloud.chatroom.demotion;

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/demotion.html#add
             * 添加应用内聊天室降级消息
             *
             * */
            String[]       messageType = { "RC:VcMsg", "RC:ImgTextMsg", "RC:ImgMsg" };
            ResponseResult addResult   = demotion.Add(messageType);

            Console.WriteLine("add demotion:  " + addResult.ToString());

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/demotion.html#remove
             * 移除应用内聊天室降级消息
             *
             * */
            ResponseResult removeResult = demotion.Remove(messageType);

            Console.WriteLine("remove demotion:  " + removeResult.ToString());


            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/demotion.html#getList
             * 添加聊天室消息优先级demo
             *
             * */
            ChatroomDemotionMsgResult demotionMsgResult = demotion.GetList();

            Console.WriteLine("get demotion:  " + demotionMsgResult.ToString());

            Console.ReadLine();
        }
Esempio n. 11
0
        /**
         * 自定义api地址
         * */
        //private static readonly String api = "http://api.cn.ronghub.com";

        static void Main(String[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api地址方式
            //RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);

            Whitelist whitelist = rongCloud.Chatroom.whiteList;

            String[] messageType = { "RC:VcMsg", "RC:ImgTextMsg", "RC:ImgMsg" };

            /**
             * API: 文档http://www.rongcloud.cn/docs/server_sdk_api/chatroom/whitelist/message.html#add
             * 添加聊天室全局禁言
             * */

            ResponseResult addResult = whitelist.Message.Add(messageType);

            Console.WriteLine("add whitelist:  " + addResult.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/whitelist/message.html#getList
             * 添加聊天室全局禁言
             * */

            ChatroomWhitelistMsgResult getResult = whitelist.Message.GetList();

            Console.WriteLine("get whitelist:  " + getResult.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/whitelist/message.html#remove
             * 添加聊天室全局禁言
             * */

            ResponseResult removeResult = whitelist.Message.Remove(messageType);

            Console.WriteLine("remove whitelist:  " + addResult.ToString());

            Console.ReadLine();
        }
Esempio n. 12
0
        static async Task Main(string[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api 地址方式
            // RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);

            Conversation Conversation = rongCloud.Conversation;

            ConversationModel conversation = new ConversationModel()
            {
                Type     = CodeUtil.ConversationType.PRIVATE.Name,
                UserId   = "uPj70HUrRSUk-ixtt7iIGc",
                TargetId = "Vu-oC0_LQ6kgPqltm_zYtI"
            };

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/conversation/conversation.html#mute
             * 设置消息免打扰
             *
             */
            ResponseResult muteConversationResult = await Conversation.Mute(conversation);

            Console.WriteLine("muteConversationResult:  " + muteConversationResult);

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/conversation/conversation.html#unmute
             * 解除消息免打扰
             *
             * */
            ResponseResult unMuteConversationResult = await Conversation.UnMute(conversation);

            Console.WriteLine("unMuteConversationResult:  " + unMuteConversationResult);
            Console.ReadLine();
        }
Esempio n. 13
0
        static void main(String[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api地址方式
            //RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);

            Gag gag = rongCloud.Chatroom.gag;

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/gag.html#add
             * 添加禁言聊天室成员方法想(在 App 中如果不让某一用户在聊天室中发言时,可将此用户在聊天室中禁言,
             * 被禁言用户可以接收查看聊天室中用户聊天信息,但不能发送消息.)获取某用户的黑名单列表方法(每秒钟限 100 次)
             */

            ChatroomMember[] members =
            {
                new ChatroomMember()
                {
                    Id = "qawr34h"
                },
                new ChatroomMember()
                {
                    Id = "qawr35h"
                }
            };
            ChatroomModel chatroom = new ChatroomModel()
            {
                Id      = "hjhf07kk",
                Members = members,
                Minute  = 5
            };

            ResponseResult result = gag.Add(chatroom);

            Console.WriteLine("addGagUser:  "******"hjhf07kk"
            };
            ListGagChatroomUserResult chatroomListGagUserResult = gag.GetList(chatroom);

            Console.WriteLine("ListGagUser:  "******"hjhf07kk",
                Members = members
            };

            ResponseResult removeResult = gag.Remove(chatroom);

            Console.WriteLine("rollbackGagUser:  " + result.ToString());

            Console.ReadLine();
        }
Esempio n. 14
0
        static async Task Main(string[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api地址方式
            //RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);

            Block block = rongCloud.Chatroom.block;

            ChatroomMember[] members =
            {
                new ChatroomMember()
                {
                    Id = "qawr34h"
                }, new ChatroomMember()
                {
                    Id = "qawr35h"
                }
            };

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/block.html#add
             *
             * 添加封禁聊天室成员方法
             */


            ChatroomModel chatroom = new ChatroomModel()
            {
                Id      = "d7ec7a8b8d8546c98b0973417209a548",
                Members = members,
                Minute  = 5
            };

            ResponseResult result = await block.Add(chatroom);

            Console.WriteLine("addBlockUser:  "******"d7ec7a8b8d8546c98b0973417209a548",
                Members = members
            };

            //ResponseResult removeResult = block.remove(chatroom);
            //Console.WriteLine("removeResult:  " + removeResult.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/block.html#getList
             *
             * 查询被封禁聊天室成员方法
             */
            ListBlockChatroomUserResult getResult = await block.GetList("d7ec7a8b8d8546c98b0973417209a548");

            Console.WriteLine("getListBlockUser:  " + getResult);
            Console.ReadLine();
        }
Esempio n. 15
0
 public void Test_GetInstance()
 {
     _rongCloud = RongCloud.GetInstance("mgb7ka1nmdhag", "lYxcetoUuCZ");
     _rongCloud.ShouldNotBeNull();
 }
Esempio n. 16
0
        static void Main(String[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api地址方式
            //RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);

            Chatroom chatroom = rongCloud.Chatroom;

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/chatroom.html#create
             *
             * 创建聊天室
             *
             * */
            ChatroomModel[] chatrooms =
            {
                new ChatroomModel()
                {
                    Id = "OIBbeKlkx", Name = "chatroomName1"
                },
                new ChatroomModel()
                {
                    Id = "chatroomId2", Name = "chatroomName2"
                }
            };
            ResponseResult result = chatroom.Create(chatrooms);

            Console.WriteLine("create:  " + result.ToString());

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/chatroom.html#destory
             * 销毁聊天室
             *
             * */
            ChatroomModel chatroomModel = new ChatroomModel()
            {
                Id = "chatroomId2"
            };

            //ResponseResult chatroomDestroyResult = chatroom.Destroy(chatroomModel);
            //Console.WriteLine("destroy:  " + chatroomDestroyResult.ToString());


            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/chatroom.html#getMembers
             * 查询聊天室成员demo
             *
             * */

            chatroomModel = new ChatroomModel()
            {
                Id    = "OIBbeKlkx",
                Count = 10,
                Order = 1
            };

            ChatroomUserQueryResult chatroomQueryUserResult = chatroom.Get(chatroomModel);

            Console.WriteLine("queryUser:  "******"e5ZnCtyfE",
                ChatroomId = "OIBbeKlkx"
            };

            CheckChatRoomUserResult checkMemberResult = chatroom.IsExist(member);

            Console.WriteLine("checkChatroomUserResult:  " + checkMemberResult.IsInChrm);
            Console.ReadLine();
        }
Esempio n. 17
0
        /**
         * 本地调用测试
         *
         * @param args
         * @throws Exception
         */
        static void Main(String[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api 地址方式
            // RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);

            Group Group = rongCloud.group;

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#create
             *
             * 创建群组方法
             *
             */
            GroupMember[] members = { new GroupMember()
                                      {
                                          Id = "Vu-oC0_LQ6kgPqltm_zYtI"
                                      }, new GroupMember()
                                      {
                                          Id = "uPj70HUrRSUk-ixtt7iIGc"
                                      } };


            GroupModel group = new GroupModel()
            {
                Id      = "goupId1.net",
                Members = members,
                Name    = "groupName"
            };

            Result groupCreateResult = (Result)Group.Create(group);

            Console.WriteLine("group create result:  " + groupCreateResult.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#sync
             *
             *  同步用户所属群组方法
             */

            GroupModel group1 = new GroupModel()
            {
                Id   = "goupId1.net",
                Name = "groupName1"
            };

            GroupModel group2 = new GroupModel()
            {
                Id   = "goupId2.net",
                Name = "groupName2"
            };

            GroupModel[] groups = { group1, group2 };
            UserGroup    user   = new UserGroup()
            {
                Id     = "Vu-oC0_LQ6kgPqltm_zYtI",
                Groups = groups
            };


            Result syncResult = (Result)Group.Sync(user);

            Console.WriteLine("group sync:  " + syncResult.ToString());

            Console.WriteLine("get group users:" + Group.Get(new GroupModel()
            {
                Id = "goupId1.NET"
            }).ToString());


            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#refresh
             *  刷新群组信息方法
             */
            //GroupMember[] members = {new GroupMember().setId("ghJiu7H1"),new GroupMember().setId("ghJiu7H2")};

            group = new GroupModel()
            {
                Id   = "goupId1.NET",
                Name = "groupName"
            };

            Result refreshResult = (Result)Group.Update(group);

            Console.WriteLine("refresh:  " + refreshResult.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#join
             *
             * 邀请用户加入群组
             *
             */
            group = new GroupModel()
            {
                Id      = "goupId1.NET",
                Members = members,
                Name    = "groupName"
            };

            Result groupInviteResult = (Result)rongCloud.group.Invite(group);

            Console.WriteLine("invite:  " + groupInviteResult.ToString());

            Console.WriteLine("get group users:" + Group.Get(new GroupModel()
            {
                Id = "goupId1.NET"
            }).ToString());


            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#join
             *
             * 用户加入指定群组
             *
             */
            group = new GroupModel()
            {
                Id      = "goupId1.NET",
                Members = members,
                Name    = "groupName"
            };

            Result groupJoinResult = (Result)Group.Join(group);

            Console.WriteLine("join:  " + groupJoinResult.ToString());
            Console.WriteLine("get group users:" + Group.Get(new GroupModel()
            {
                Id = "goupId1.NET"
            }).ToString());


            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#getMembers
             *
             * 查询群成员方法
             *
             */
            group = new GroupModel()
            {
                Id = "goupId1.NET"
            };
            GroupUserQueryResult getMemberesult = Group.Get(group);

            Console.WriteLine("group getMember:  " + getMemberesult.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#quit
             *
             * 退出群组
             *
             */
            group = new GroupModel()
            {
                Id      = "goupId1.NET",
                Members = new GroupMember[] { new GroupMember()
                                              {
                                                  Id = "uPj70HUrRSUk-ixtt7iIGc"
                                              } },
                Name = "groupName"
            };

            Result groupQuitResult = (Result)Group.Quit(group);

            Console.WriteLine("quit:  " + groupQuitResult.ToString());
            Console.WriteLine("get group users:" + Group.Get(new GroupModel()
            {
                Id = "goupId1.NET"
            }).ToString());


            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/group.html#dismiss
             *
             * 解散群组
             *
             */
            members = new GroupMember[] { new GroupMember()
                                          {
                                              Id = "Vu-oC0_LQ6kgPqltm_zYtI"
                                          } };

            group = new GroupModel()
            {
                Id      = "goupId1.NET",
                Members = members
            };

            Result groupDismissResult = (Result)Group.Dismiss(group);

            Console.WriteLine("dismiss:  " + groupDismissResult.ToString());
            Console.ReadLine();
        }
Esempio n. 18
0
        static void Main(String[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api 地址方式
            // RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);

            SensitiveWord SensitiveWord = rongCloud.Sensitiveword;

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/sensitive/sensitive.html#add
             *
             * 添加替换敏感词方法
             *
             * */
            SensitiveWordModel sentiveWord = new SensitiveWordModel()
            {
                Type    = 0,
                Keyword = "黄赌黄",
                Replace = "***"
            };

            ResponseResult addesult = SensitiveWord.Add(sentiveWord);

            Console.WriteLine("sentiveWord add:  " + addesult.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/sensitive/sensitive.html#add
             *
             * 添加替换敏感词方法
             *
             * */
            sentiveWord = new SensitiveWordModel()
            {
                Type    = 1,
                Keyword = "黄赌黄"
            };

            ResponseResult addersult = SensitiveWord.Add(sentiveWord);

            Console.WriteLine("sentiveWord  add replace :  " + addersult.ToString());

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/sensitive/sensitive.html#getList
             * 查询敏感词列表方法
             *
             * */
            ListWordfilterResult result = SensitiveWord.GetList(1);

            Console.WriteLine("getList:  " + result.ToString());

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/sensitive/sensitive.html#remove
             * 移除敏感词方法(从敏感词列表中,移除某一敏感词。)
             *
             * */

            ResponseResult removeesult = SensitiveWord.Remove("黄赌黄");

            Console.WriteLine("SensitivewordDelete:  " + removeesult.ToString());


            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/sensitive/sensitive.html#remove
             * 批量移除敏感词方法(从敏感词列表中,批量移除某一敏感词。)
             *
             * */
            String[]       words             = { "黄赌毒" };
            ResponseResult batchDeleteResult = SensitiveWord.BatchDelete(words);

            Console.WriteLine("SensitivewordbatchDelete:  " + batchDeleteResult.ToString());
            Console.ReadLine();
        }
Esempio n. 19
0
        /**
         * 自定义api地址
         * */
        //private static readonly String api = "http://api.cn.ronghub.com";

        /**
         * 本地调用测试
         *
         *
         * @throws Exception
         */
        static void Main(String[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api 地址方式
            // RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);

            Gag   gag   = rongCloud.Group.Gag;
            Group Group = rongCloud.Group;

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/gag.html#add
             * 添加禁言群成员方法
             */

            GroupMember[] members = { new GroupMember()
                                      {
                                          Id = "Vu-oC0_LQ6kgPqltm_zYtI"
                                      }, new GroupMember()
                                      {
                                          Id = "uPj70HUrRSUk-ixtt7iIGc"
                                      } };

            GroupModel group = new GroupModel()
            {
                Id      = "goupId1.NET",
                Members = members,
                Name    = "groupName",
                Minute  = 5
            };

            Result groupCreateResult = (Result)Group.Create(group);

            Console.WriteLine("group create result:  " + groupCreateResult.ToString());
            Console.WriteLine("get group users:" + Group.Get(new GroupModel()
            {
                Id = "goupId1.NET"
            }).ToString());


            Result result = gag.Add(group);

            Console.WriteLine("group.gag.add:  " + result.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/gag.html#getList
             * 查询被禁言群成员
             */
            ListGagGroupUserResult groupLisGagUserResult = gag.GetList("goupId1.NET");

            Console.WriteLine("group.gag.getList:  " + groupLisGagUserResult.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/group/gag.html#remove
             * 移除禁言群成员
             */
            group = new GroupModel()
            {
                Id      = "goupId1.NET",
                Members = members
            };


            Result groupRollBackGagUserResult = gag.Remove(group);

            Console.WriteLine("group.gag.remove:  " + groupRollBackGagUserResult.ToString());
            Console.ReadLine();
        }
        /**
         * 自定义api地址
         * */
        //private static readonly String api = "http://api.cn.ronghub.com";

        static void Main(String[] args)
        {
            RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret);
            //自定义 api 地址方式
            //RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);

            Private Private = rongCloud.message.msgPrivate;
            // TODO
            MsgSystem system = rongCloud.message.system;

            methods.messages.group.Group group = rongCloud.message.group;
            Chatroom   chatroom   = rongCloud.message.chatroom;
            Discussion discussion = rongCloud.message.discussion;
            History    history    = rongCloud.message.history;

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/system.html#send
             *
             * 发送系统消息
             *
             */
            String[]      targetIds     = { "uPj70HUrRSUk-ixtt7iIGc" };
            SystemMessage systemMessage = new SystemMessage()
            {
                SenderId         = "Vu-oC0_LQ6kgPqltm_zYtI",
                TargetId         = targetIds,
                ObjectName       = txtMessage.GetType(),
                Content          = txtMessage,
                PushContent      = ".NET this is a push system",
                PushData         = "{'pushData':'.NET hello'}",
                IsPersisted      = 0,
                IsCounted        = 0,
                ContentAvailable = 0
            };

            ResponseResult result = rongCloud.message.system.Send(systemMessage);

            Console.WriteLine("send system message:  " + result.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/system.html#sendTemplate
             *
             * 发送系统模板消息方法
             *
             */
            StreamReader file = null;

            try
            {
                file = System.IO.File.OpenText("jsonsource/message/TemplateMessage.json");
                TemplateMessage template = JsonConvert.DeserializeObject <TemplateMessage>(file.ReadToEnd());
                ResponseResult  messagePublishTemplateResult = system.SendTemplate(template);

                Console.WriteLine("send systemTemplate message:  " + messagePublishTemplateResult.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                file.Close();
            }


            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/system.html#sendTemplate
             *
             * 发送系统模板消息方法
             *
             */
            BroadcastMessage message = new BroadcastMessage()
            {
                SenderId   = "Vu-oC0_LQ6kgPqltm_zYtI",
                ObjectName = txtMessage.GetType(),
                Content    = txtMessage,
                Os         = "Android"
            };

            ResponseResult broadcastResult = rongCloud.message.system.Broadcast(message);

            Console.WriteLine("send broadcast:  " + broadcastResult.ToString());


            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/private.html#send
             *
             * 发送单聊消息
             * */
            PrivateMessage privateMessage = new PrivateMessage()
            {
                SenderId         = "Vu-oC0_LQ6kgPqltm_zYtI",
                TargetId         = targetIds,
                ObjectName       = txtMessage.GetType(),
                Content          = txtMessage,
                PushContent      = ".NET this is a push private",
                PushData         = "{\"pushData\":\".NET hello\"}",
                VerifyBlacklist  = 0,
                IsPersisted      = 0,
                IsCounted        = 0,
                ContentAvailable = 0,
                IsIncludeSender  = 0
            };

            ResponseResult privateResult = Private.Send(privateMessage);

            Console.WriteLine("send private message:  " + privateResult.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/private.html#sendTemplate
             *
             * 发送单聊模板消息方法
             */
            try
            {
                file = System.IO.File.OpenText("jsonsource/message/TemplateMessage.json");
                TemplateMessage template = JsonConvert.DeserializeObject <TemplateMessage>(file.ReadToEnd());
                ResponseResult  messagePublishTemplateResult = Private.SendTemplate(template);

                Console.WriteLine("send privateTemplate message:  " + messagePublishTemplateResult.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                file.Close();
            }

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/private.html#recall
             *
             * 撤回单聊消息
             * */
            RecallMessage recallMessage = new RecallMessage()
            {
                SenderId = "0fn8TiuHTUgjrZ1QJ8o50M",
                TargetId = "qHPBAoUS6DmEBtJH72RSDi",
                UId      = "5H6P-CGC6-44QR-VB3R",
                SentTime = "1519444243981"
            };

            ResponseResult recallPrivateResult = (ResponseResult)Private.Recall(recallMessage);

            Console.WriteLine("recall private:  " + recallPrivateResult.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/group.html#send
             *
             * 群组消息
             * */
            GroupMessage groupMessage = new GroupMessage()
            {
                SenderId         = "Vu-oC0_LQ6kgPqltm_zYtI",
                TargetId         = new string[] { "STRe0shISpQlSOBvek1FfU" },
                ObjectName       = txtMessage.GetType(),
                Content          = txtMessage,
                PushContent      = "this is a push",
                PushData         = "{\"pushData\":\"hello\"}",
                IsPersisted      = 0,
                IsCounted        = 0,
                IsIncludeSender  = 0,
                ContentAvailable = 0
            };

            ResponseResult groupResult = group.Send(groupMessage);

            Console.WriteLine("send Group message:  " + groupResult.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/group.html#recall
             *
             * 群组撤回消息
             * */
            recallMessage = new RecallMessage()
            {
                SenderId = "sea9901",
                TargetId = "markoiwm",
                UId      = "5GSB-RPM1-KP8H-9JHF",
                SentTime = "1507778882124"
            };

            ResponseResult recallMessageResult = (ResponseResult)group.Recall(recallMessage);

            Console.WriteLine("send recall group message:  " + recallMessageResult.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/group.html#sendMention
             *
             * 群组@消息
             * */
            //要@的人
            String[] mentionIds = { "uPj70HUrRSUk-ixtt7iIGc", "Vu-oC0_LQ6kgPqltm_zYtI" };

            MentionedInfo mentionedInfo = new MentionedInfo(1, mentionIds, "");
            //@内容
            MentionMessageContent content = new MentionMessageContent(txtMessage, mentionedInfo);

            MentionMessage mentionMessage = new MentionMessage()
            {
                SenderId         = "Vu-oC0_LQ6kgPqltm_zYtI",
                TargetId         = new string[] { "STRe0shISpQlSOBvek1FfU" },
                ObjectName       = txtMessage.GetType(),
                Content          = content,
                PushContent      = "this is a push",
                PushData         = "{\"pushData\":\"hello\"}",
                IsPersisted      = 0,
                IsCounted        = 0,
                IsIncludeSender  = 0,
                ContentAvailable = 0
            };
            ResponseResult mentionResult = rongCloud.message.group.SendMention(mentionMessage);

            Console.WriteLine("group mention result:  " + mentionResult.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/discussion.html#send
             *
             * 发送讨论组消息
             * */
            String[]          discussionIds     = { "lijhGk87", "lijhGk88" };
            DiscussionMessage discussionMessage = new DiscussionMessage()
            {
                SenderId         = "JuikH78ko",
                TargetId         = discussionIds,
                ObjectName       = txtMessage.GetType(),
                Content          = txtMessage,
                PushContent      = "this is a push",
                PushData         = "{\"pushData\":\"hello\"}",
                IsPersisted      = 0,
                IsCounted        = 0,
                IsIncludeSender  = 0,
                ContentAvailable = 0
            };

            ResponseResult discussionResult = discussion.Send(discussionMessage);

            Console.WriteLine("send discussion message:  " + discussionResult.ToString());

            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/discussion.html#recall
             *
             * 撤回讨论组消息
             * */
            recallMessage = new RecallMessage()
            {
                SenderId = "sea9901",
                TargetId = "IXQhMs3ny",
                UId      = "5GSB-RPM1-KP8H-9JHF",
                SentTime = "1519444243981"
            };
            ResponseResult recallDiscussionResult = (ResponseResult)discussion.Recall(recallMessage);

            Console.WriteLine("recall discussion message:  " + recallDiscussionResult.ToString());


            /**
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/chatroom.html#send
             *
             * 聊天室消息
             * */

            String[] chatroomIds = { "OIBbeKlkx" };

            CustomTxtMessage ctm             = new CustomTxtMessage("hello world");
            ChatroomMessage  chatroomMessage = new ChatroomMessage()
            {
                SenderId   = "aP9uvganV",
                TargetId   = chatroomIds,
                Content    = ctm,
                ObjectName = ctm.GetType()
            };

            ResponseResult chatroomResult = chatroom.Send(chatroomMessage);

            Console.WriteLine("send chatroom message:  " + chatroomResult.ToString());


            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/chatroom.html#broadcast
             *
             * 聊天室广播消息
             *
             * 此功能需开通专有服务: http://www.rongcloud.cn/deployment#overseas-cloud
             *
             * */
            chatroomMessage = new ChatroomMessage()
            {
                SenderId   = "aP9uvganV",
                Content    = txtMessage,
                ObjectName = txtMessage.GetType()
            };


            ResponseResult chatroomBroadcastresult = chatroom.Broadcast(chatroomMessage);

            Console.WriteLine("send chatroom broadcast message:  " + chatroomBroadcastresult.ToString());


            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/history.html#get
             *
             * 获取历史消息日志文件
             *
             * */

            HistoryMessageResult historyMessageResult = history.Get("2019011711");

            Console.WriteLine("get history  message:  " + historyMessageResult.ToString());

            /**
             *
             * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/message/history.html#get
             *
             * 删除历史消息日志文件
             *
             * */
            ResponseResult removeHistoryMessageResult = history.Remove("2018030210");

            Console.WriteLine("remove history  message:  " + removeHistoryMessageResult.ToString());
            Console.ReadLine();
        }
Esempio n. 21
0
 public Test()
 {
     _client = RongCloud.GetInstance(appKey, appSecret);
 }