点击或拖拽改变大小

NetworkBaseToken 属性

网络类的身份令牌,在hsl协议的模式下会有效,在和设备进行通信的时候是无效的
Network-type identity tokens will be valid in the hsl protocol mode and will not be valid when communicating with the device

命名空间:  HslCommunication.Core.Net
程序集:  HslCommunication (在 HslCommunication.dll 中) 版本:12.1.2.0 (12.1.2.0)
语法
public Guid Token { get; set; }

属性值

类型:Guid
备注
适用于Hsl协议相关的网络通信类,不适用于设备交互类。
示例
此处以 NetSimplifyServer 服务器类及 NetSimplifyClient 客户端类的令牌设置举例
Client示例
NetSimplifyClient simplifyClient = new NetSimplifyClient( "127.0.0.1", 12345 );

// 这个toeken需要和服务器的设置的token相匹配才可以
simplifyClient.Token = new Guid( "787f9607-dd7a-4ba7-9f98-769d24de05df" );
Server示例
private NetSimplifyServer simplifyServer = null;

public void TokenServerExample( )
{
    simplifyServer = new NetSimplifyServer( );
    simplifyServer.Token = new Guid( "787f9607-dd7a-4ba7-9f98-769d24de05df" );

    simplifyServer.ReceiveStringEvent += SimplifyServer_ReceiveStringEvent;
    simplifyServer.ServerStart( 12345 );
}

private void SimplifyServer_ReceiveStringEvent( HslCommunication.Core.Net.AppSession session, HslCommunication.NetHandle handle, string data )
{
    // 示例情况,接收到数据后返回消息
    simplifyServer.SendMessage( session, handle, "Back:" + data );
}
参见