Example #1
0
 public void BuildHeartBeatPacket_Test()
 {
     byte[] result = CommonService.BuildHeartBeatPacket("10153302696068");
     Console.WriteLine(BitConverter.ToString(result));
 }
Example #2
0
		private void DoLogin()
		{
#if !FAKE_LOGIN

			LoginResponseResult result = srunSvc.Login();
			if (result.Status == ResponseStatus.Success)
			{
				string uid = result.Uid;
				byte[] packet = CommonService.BuildHeartBeatPacket(uid);
				srunSvc.Status = new StatusInfo(uid, packet);

				srunSvc.HeartBeat();
#else
            LoginResponseResult result = new LoginResponseResult(ResponseStatus.Success, "");
#endif

				srunSvc.Status.IsLogin = true;
				// Update UI
				lblHint.Text = "已登录\n\n时间戳偏差为:" + result.TimeOffset;
#if FAKE_LOGIN
            lblHint.Text += "\t FAKE_LOGIN";
#endif
				txtAddress.Enabled = false;
				txtPassword.Enabled = false;
				txtUsername.Enabled = false;
				btnLogin.Enabled = false;

				// Hide Form
				this.WindowState = FormWindowState.Minimized;

				// Get notify message
				if (srunSvc.Config.NotifyDuration > 0)
				{
					notifyMsg = srunSvc.GetNotifyMessage();
					ntyIcon.BalloonTipText = notifyMsg;
					ntyIcon.ShowBalloonTip(srunSvc.Config.NotifyDuration * 1000);
				}
#if !FAKE_LOGIN
			}
			else
			{
				lblHint.Text = CodeInfo.InfoDict.ContainsKey(result.Message) ? CodeInfo.InfoDict[result.Message] : result.Message;
			}
			if (srunSvc.Config.LogLevel == SimpleLogger.LogLevel.Debug)
			{
				CommonService.logger.AppendLog("Login.\r\n"
					+ "Login url: {0}\r\n" + "Login port: {1}\r\n"
					+ "Server IP: {2}\r\n" + "Heartbeat port: {3} \r\n" + "Heartbeat interval: {4} ms\r\n"
					+ "Logout url: {5}\r\n" + "Log level: {6}\r\n"
					+ "Message url: {7}\r\n" + "Notify duration: {8} second(s)\r\n"
					+ "Query url: {9}\r\n" + "Timestamp offset: {10}\r\n"
					+ "Username: {11}\r\n" + "Uid: {12}\r\n",
					srunSvc.Config.LoginUrl, srunSvc.Config.LoginPort,
						srunSvc.Config.ServerIP, srunSvc.Config.HeartBeatPort, srunSvc.Config.HeartBeatInterval,
						srunSvc.Config.LogoutUrl, srunSvc.Config.LogLevel,
						srunSvc.Config.MessageUrl, srunSvc.Config.NotifyDuration,
						srunSvc.Config.QueryUrl, srunSvc.Config.TimestampOffset,
						srunSvc.Config.Username, result.Uid
					);

			}

#endif
		}