FreeIM/ImServer.cs
(开头部分) 6KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
#if ns20
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
public static class FreeImServerExtenssions
{
static bool isUseWebSockets = false;
/// <summary>
/// 启用 ImServer 服务端
/// </summary>
/// <param name="app"></param>
/// <param name="options"></param>
/// <returns></returns>
public static IApplicationBuilder UseFreeImServer(this IApplicationBuilder app, ImServerOptions options)
{
app.Map(options.PathMatch, appcur =>
{
var imserv = new ImServer(options);
if (isUseWebSockets == false)
{
isUseWebSockets = true;
appcur.UseWebSockets();
}
appcur.Use((ctx, next) =>
imserv.Acceptor(ctx, next));
});
return app;
}
}
/// <summary>
/// im 核心类实现的配置所需
/// </summary>
public class ImServerOptions : ImClientOptions
{
/// <summary>
/// 设置服务名称,它应该是 servers 内的一个
/// </summary>
public string Server { get; set; }
}
class ImServer : ImClient
{
protected string _server { get; set; }
public ImServer(ImServerOptions options) : base(options)
{
_server = options.Server;
_redis.Subscribe($"{_redisPrefix}Server{_server}", RedisSubScribleMessage);
后面还有 109 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
