Jc.IM 1.0.7

dotnet add package Jc.IM --version 1.0.7                
NuGet\Install-Package Jc.IM -Version 1.0.7                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Jc.IM" Version="1.0.7" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Jc.IM --version 1.0.7                
#r "nuget: Jc.IM, 1.0.7"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Jc.IM as a Cake Addin
#addin nuget:?package=Jc.IM&version=1.0.7

// Install Jc.IM as a Cake Tool
#tool nuget:?package=Jc.IM&version=1.0.7                

IM 通讯模块

基于Redis订阅 创建的通讯服务

目前支持

1。点对点发送消息

2。群组发送消息

API

启动 中间件

app.UseJcImServer(new JcImOptions()
{
    RedisCon = "192.168.1.83:6379,poolsize=5,password=password123456",
});

JcImOptions:

/// <summary>
/// Redis连接字符串
/// </summary>
public string RedisCon { get; set; }

/// <summary>
/// websocket请求的路径:可空
/// ws://127.0.0.1/{WSPath}
/// </summary>
public string WSPath { get; set; }

/// <summary>
/// 是否启用安全模式
/// 启用:需要通过API获取连接地址
/// 禁用:任何人可以连接到服务
/// </summary>
public bool IsSecurity { get; set; }

获取在线客户端

JcImServerExt.GetClientOnline()

获取分组内成员

JcImServerExt.GetGroupClients(string groupName)

获取成员分组

JcImServerExt.GetClientGroups(string clientId)

加入分组

JcImServerExt.JoinGroup(string clientId, string groupName)

离开分组

JcImServerExt.LeaveGroup(string clientId, List<string> groupName)

事件订阅

//上线,离线 ,消息
JcImServerExt.EventBus(
    offline =>
    {
        Console.WriteLine(offline);
    },
    online =>
    {
        Console.WriteLine(online);
    }, 
    msg =>
    {
        Console.WriteLine(msg.key, msg.message);
    }
);

WebSocket指令

指令结构

{

  //当 MessageType <=3 时候 是消息内容
  //当 MessageType=4 时候 是分组ID/名称
  "Message": "文本信息",
  //接受者ID
  "ReceiverId": ["",""],
  //接收组ID|名字
  "ReceiverGroup": ["组1"],
  //消息类型
  "MessageType": 4
}

指令说明

MessageType:

public enum enmMsgType
{
    /// <summary>
    /// 文本
    /// </summary>
    text=0,
    
    /// <summary>
    /// 图片
    /// </summary>
    image=1,
    
    /// <summary>
    /// 文件地址
    /// </summary>
    fileurl=2,
    
    /// <summary>
    /// 链接分享
    /// </summary>
    shareurl=3,
    
    /// <summary>
    /// 加入群组
    /// Message=群组名称
    /// </summary>
    joingroup=4,
    
    /// <summary>
    /// 离开群组
    /// </summary>
    leavegroup=5,
    
    /// <summary>
    /// 查看我的群组
    /// </summary>
    mygroup=6,
}

websocket接入

ws://192.168.1.1/wspath?token=id

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.7 259 3/7/2023
1.0.6 388 8/18/2022
1.0.5 354 8/18/2022
1.0.4 384 8/18/2022
1.0.1 408 3/17/2022