外观
新建Im服务端项目 8.6.0
项目介绍
业务和推送分离设计,终端连接永不更新重启
MyImServer
,业务代码全部在MyApp
项目编写,因此重启MyApp
项目不会造成连接断开。每个
MyImServer
管理着对应的终端连接,当接收到redis
订阅消息后,向对应的终端连接推送数据。当业务应用
imconfig.json
开启 im 时,同时要启动 im 服务器集群地址中的 im 服务端项目
安装或升级模板
cs
dotnet new install ZhonTai.Template.IMServer
升级模板命令和安装模板命令相同
安装指定版本
cs
dotnet new install ZhonTai.Template.IMServer::9.0.0
查看帮助
cs
dotnet new MyIMServer -h
-p, --port <port> Port settings
类型: int
默认: 17010
创建Im服务端项目
cs
dotnet new MyIMServer -n MyCompanyName.MyIMServer
自定义Im服务端端口
cs
dotnet new MyIMServer -n MyCompanyName.MyIMServer -p 17010
appsettings.json 应用程序配置
appsettings.json
json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ImServerOptions": {
"RedisClient": "127.0.0.1:6379,password=,poolsize=10,defaultDatabase=6",
"Servers": "127.0.0.1:6010",
"Server": "127.0.0.1:6010"
}
}
注意
redis
默认数据库必须要和业务应用 imconfig.json
中的默认数据库保存一致
launchSettings.json 开发启动配置
launchSettings.json
json
{
"profiles": {
"MyIMServer.Host": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:17010"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:17010",
"sslPort": 0
}
}
}