适用于AbpBoilerplate的RocketChat Api库
RocketChat
适用于AbpBoilerplate的RocketChat Api库
Rocket.Chat 是一个免费、开源、可扩展、高度可定制且安全的平台,可让您与团队进行交流和协作、共享文件和实时聊天(https://www.rocket.chat/)
Rocket.Chat服务的安装请阅读Rocket.Chat 安装与设置启动项
快速开始
一. 在项目中引用AbpBoilerplate.RocketChat。
dotnet add package AbpBoilerplate.RocketChat
二. 添加RocketChatModule模块依赖
[DependsOn(typeof(RocketChatModule))]
public class CoreModule : AbpModule
三. appsettings.json配置文件中,添加服务相关配置
"Im": {
"Provider": "RocketChat",
"Address": "http://localhost:3000/", //rocketchat服务地址
"WebSocketAddress": "ws://localhost:3000/", //websocket地址
"AdminUserName": "super", //AdminUser的用户名
"AdminPassword": "123qwe", //AdminUser的密码
"DefaultPassword": "123qwe" //创建用户时的默认密码
}
...
注意:AdminUserName和AdminPassword请填写配置RocketChat时的初始用户用名与密码。
四. 在构造函数中注入服务,可用的服务如下
public class ImManager : DomainService
{
public ImManager(
IRocketChatConfiguration rocketChatConfiguration,
IocManager iocManager,
IAuthenticationService authenticationService,
IFileRestClientService fileRestClientService,
IChatService chatService,
IUsersService usersService,
IChannelsService channelsService,
IRoomService roomService,
IAssetsService assetsService,
IAutoTranslateService autoTranslateService,
ICommandsService commandsService,
IEmojisService emojisService)
...
五. 在编写的领域服务方法中调用,如发送消息方法可编写如下
public async Task<Result<MessageResult>> SendMessage(string content, string roomId)
{
var model = new SendMessage();
model.Message = new MessageInput()
{
Content = content,
RoomId = roomId,
TimeStamp = DateTime.Now,
};
model.RoomId = roomId;
return await chatService.SendMessage(model);
}
作者信息
作者:林小
邮箱:jevonsflash@qq.com
License
The MIT License (MIT)
项目地址
本文来自博客园,作者:林晓lx,转载请注明原文链接:https://www.cnblogs.com/jevonsflash/p/17113122.html
分类:
.NET
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战