跳到主要内容
版本:2.x

连接

是否连接

namespace Serein.Core.Services.Network.Connection;

public partial class WsConnectionManager
{
public bool Active { get; }
}

启动

namespace Serein.Core.Services.Network.Connection;

public partial class WsConnectionManager
{
public void Start();
}
  • 若已连接则会报错,可用try...catch捕获

停止

namespace Serein.Core.Services.Network.Connection;

public partial class WsConnectionManager
{
public void Stop();
}
  • 若未连接则会报错,可用try...catch捕获

发送文本

using System.Threading.Tasks;

namespace Serein.Core.Services.Network.Connection;

public partial class WsConnectionManager
{
public Task SendDataAsync(string data);
}
参数类型说明
textstring发送的内容

发送私聊消息

using System.Threading.Tasks;

namespace Serein.Core.Services.Network.Connection;

public partial class WsConnectionManager
{
public Task SendPrivateMsgAsync(long target, string message);
public Task SendPrivateMsgAsync(string target, string message);
}
参数类型说明
targetlong | string用户Id
messagestring消息

发送群聊消息

using System.Threading.Tasks;

namespace Serein.Core.Services.Network.Connection;

public partial class WsConnectionManager
{
public Task SendGroupMsgAsync(long target, string message);
public Task SendGroupMsgAsync(string target, string message);
}
参数类型说明
targetlong | string群聊Id
messagestring消息