创建和初始化连接后,可以从指定的逻辑单元(LU)接收信息。 使用会话集成器接收信息的主要方法是SessionLU0.Receive
。
发送和接收消息后,必须断开与会话集成器会话的连接。
使用 LU0 会话集成器接收信息
使用 SessionLU0.Receive 并
SessionLU0data
等待来自 LU 的数据。Receive
允许你设置等待信息所需的最大时长,以及是否要发送自动确认。Receive
返回对象SessionLU0Data
。
示例:
下面的代码示例演示如何使用 LU0 的会话集成器接收信息。
private void CreateSession_Click(object sender, EventArgs e)
{
try
{
LUName.Text = LUName.Text.Trim();
if (LUName.Text.Length == 0)
{
MessageBox.Show("You must fill out the LU or Pool Name");
return;
}
_session = new SessionLU0(); _session.Connect("LogicalUnitName=" + LUName.Text, SessionLU0InitType.SSCP);
// Receive the logon screen.
SessionLU0Data receivedData = _session.Receive(20000, true); // Trace out the received data.
TraceData(false, receivedData.Data, receivedData.Indication);
// Disable every button and text box.
DisableEverything();
// Insert User/Password.
EnableInsertUserId();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
有关代码示例的详细信息,请参阅 LU0 代码示例的会话集成器。