|
public bool login(string ip, int port, string usrName, string psw)
{
m_server.ip = ip;
m_server.port = port;
m_server.usrName = usrName;
m_server.psw = psw;
m_server.ukeyid = "";
m_server.ukeycode = "";
m_serverParam = new BVCU_ServerParam
{
iSize = System.Runtime.InteropServices.Marshal.SizeOf(m_serverParam),
pUserData = IntPtr.Zero,
szServerAddr = Encoding.UTF8.GetBytes(ip),
iServerPort = port,
szClientID = Encoding.UTF8.GetBytes(""),
szUserAgent = Encoding.UTF8.GetBytes("login_server"),
szUserName = Encoding.UTF8.GetBytes("admin"),
szPassword = Encoding.UTF8.GetBytes("123456"),
iCmdProtoType = 0,
iTimeOut = 60 * 1000,
OnNotify = new EventHandle().NotigfBack,
OnEvent = new EventHandle().EventCB,
OnCommand = new EventHandle().CommandCB
};
try
{
int ret = BVCUFuc.BVCU_Login(ref session, ref m_serverParam);
BVCU.FAILED(ret);
// 登录成功
// ------------------------------ 获取登录(Session)信息 ------------------------------
var res = BVCUFuc.BVCU_GetSessionInfo(session, ref bs);
}
catch (Exception ex)
{
Console.WriteLine("1212");
}
return true;
}
#region 登录服务器
Session sd = new Session();
sd.login("120.25.247.85", 9701, "admin", "123456");
#endregion
|
|